MENU

RouterOS解析动态域名自动更新PPTP网卡IP

May 10, 2019 • Read: 1848 • Linux阅读设置

适用:ROS连接没有固定IP的PPTP时使用
脚本更新网卡时根据网卡备注查找,请确认备注正确。

:global xin

:global adb

ip dns cache flush

#上面这一行在测试环境下使用,如果真实环境请注释

:set xin [resolve www.123.com]

#域名请修改为自己的域名

:set adb [/interface pptp-client get [find comment ="toserver"] connect-to]

#查找是基于备注查找,如果你的备注是123

#那么将comment ="toserver"中的toserver改为123

:if ($xin !=$adb) do={

/interface pptp-client set [/interface pptp-client find comment ="toserver"] connect-to=$xin

/interface pptp-client enable [/interface pptp-client find comment ="toserver"]

/ip firewall filter set [/ip firewall filter find comment="toserver"] src-address=$xin

}

其它协议的设定同理,更换协议名即可。

Archives QR Code
QR Code for this page
Tipping QR Code