:global new
:global old
:global status
:set status [/interface get [/interface find name=("pppoe-out2")] running]
:if ($status=true) do={
:set new [/ip address get [/ip address find dynamic=yes interface=("pppoe-out2")] address]
:set new [:pick $new 0 ([:len $new] -3)]
:set old [/ip ipsec peer get [find comment=("Global IP")] address]
:if (!($new=$old)) do={
/ip ipsec peer set [/ip ipsec peer find comment=("Global IP")] address=$new
}}

1,请将 pppoe out2 替换成你adsl相同的名称
2,请将/ip ipsec peer 替换成您需要自动更新公网IP的选项,并设置comment 为 Global IP . 或是更改为您自已方便记忆的标签,并与上面代码同步修改就可以了。

作者 Qi, Asura

发表评论

您的电子邮箱地址不会被公开。