{
WAN外网接口
:local wan pppoe-out0
:local comm out0
自定义IP地址变量
:local newip
获取接口IP地址
:set newip [ /ip address get [/ip address find interface=$wan ] address ]
:set newip [:pick $newip 0 [:find $newip “/”]]
自定义IP地址变量
:local oldip
获取dst规则设置的IP地址
:set oldip [/ip firewall nat get [/ip firewall nat find comment=$comm ] dst-address]
判断修改IP
:if ( $oldip != $newip ) do= {
:foreach i in= [/ip firewall nat find in-interface=$wan] do= {/ip firewall nat set $i dst-address=$newip}
:foreach i in= [/ip firewall nat find out-interface=$wan] do= {/ip firewall nat set $i to-address=$newip}
:log error ($wan.” dst.address is update success.”)
} else= {
:log error ($wan.” dst.address is not need to update.”)
}
}
|