|
|
发表于 2020-2-27 17:43:24
|
显示全部楼层
本帖最后由 技术支持 于 2020-2-27 17:44 编辑
1.建议用netwatch进行监测,在up和down里添加脚本
2.脚本参考(这是个根据IP地址变化修改回流IP的脚本):
:do {
:local ether
#以下不需要修改
:set ether "pppoe-internet"
:local oldip [/ip firewall nat get [/ip firewall nat find to-ports ="9031" chain=dstnat to-addresses =192.168.31.200 in-interface !="dcn" and in-interface !="wlan" comment="sgw" ] dst-address ]
:local newip [/ip address get [/ip address find interface=$ether ] address ]
:set newip [:pick $newip 0 [:find $newip "/"]]
:if ($oldip != $newip) do={
#修改49、50号防火墙规则,能够回流9031、10000端口流量,允许192.168.68.0地址段
/ip firewall nat set [/ip firewall nat find to-ports ="9031" chain=dstnat to-addresses =192.168.31.200 in-interface !="dcn" and in-interface !="wlan" comment="sgw" ] dst-address=$newip
/ip firewall nat set [/ip firewall nat find dst-port ="10000" to-ports ="443" chain=dstnat to-addresses =192.168.31.111 comment="sgw1" ] dst-address=$newip
:log error ("oldip: ".$oldip." newip: ".$newip)
:log error ("firewall rule 49,50 dst-address updated!")
} else={
:log error ("firewall rule 49,50 dst-address need not update!") }
} |
|