创新|开发|定制
专注于软路由|网络技术领域

DDNS动态域名脚本-ROS RouterOS 中设置changeip

申请好changeip用户名,密码,域名,对应修改下面的脚本后即可使用:

 # EDIT YOUR DETAILS / CONFIGURATION HERE(这里更改用户配置)
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 :global ddnsuser "YourChangeIPUserID"
 :global ddnspass "PASSWORD"
 :global ddnshost "MyRouterHostname.example.org"
 :global ddnsinterface "pppoe-out1"
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 # END OF USER DEFINED CONFIGURATION(用户配置更改结束,下面的命令不要动)
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 :global ddnssystem ("mt-" . [/system package get [/system package find name=system] version] )
 :global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface] address ]
 :global ddnslastip
 :if ([:len [/interface find name=$ddnsinterface]] = 0 ) do={ :log info "DDNS: No interface named $ddnsinterface, please check configuration." }
 :if ([ :typeof $ddnslastip ] = "nothing" ) do={ :global ddnslastip 0.0.0.0/0 }
 :if ([ :typeof $ddnsip ] = "nothing" ) do={
 :log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
 } else={
 :if ($ddnsip != $ddnslastip) do={
 :log info "DDNS: Sending UPDATE!"
 :log info [ :put [/tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ] ]
 :global ddnslastip $ddnsip
 } else={
 :log info "DDNS: No changes necessary."
 }
 }
 # END OF SCRIPT

运行日志:

赞(0) 打赏
转载请注明出处:Ros资源网 » DDNS动态域名脚本-ROS RouterOS 中设置changeip

评论 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏