ROS RouterBoard 系统DDNS设置
webfig或winbox界面下依次打开system-script界面,Name框输入脚本名称,本例中使用英文script1,在Source框内输入脚本内容。注意脚本中需要填写自己的用户名,密码以及需要解析的域名,同时一定要将例子中的端口名ETH-0改为你自己的WAN口名称。
pubyun、3322.org系列版本:
:global ednsuser "USERNAME" :global ednspass "PASSWORD" :global ednshost "test.3322.org" :global ednsinterface "ETH-0" :global members "http://members.3322.org/dyndns/update\?system=dyndns" :global status :global status [/interface get [/interface find name=$ednsinterface] running] :if ($status!=false) do={ :global ednslastip [:resolve $ednshost] :if ([ :typeof $ednslastip ] = nil ) do={ :global ednslastip "0" } :global ednsiph [ /ip address get [/ip address find interface=$ednsinterface ] address ] :global ednsip [:pick $ednsiph 0 [:find $ednsiph "/"]] :global ednsstr "&hostname=$ednshost&myip=$ednsip" :if ($ednslastip != $ednsip) do={ /tool fetch url="$members$ednsstr" mode=http user=$ednsuser password=$ednspass dst-path=$ednshost :delay 4 :global result [/file get $ednshost contents] :log info ($ednshost . " " .$result) /file remove $ednshost ; } }
花生壳Peanut版本:
local ipaddr local server "http://ddns.oray.com" local domain "test.vicp.net" local par "/ph/update?&hostname=$domain&myip=$ipaddr" local users "USERNAME" local paswd "PASSWORD" :set ipaddr [/ip address get [/ip address find interface=ETH-0] address] :set ipaddr [:pick $ipaddr 0 ([len $ipaddr] -3)] /tool fetch url=($server . $par) mode=http user=$users password=$paswd
最后,可以创建一个计划任务来定时运行DDNS脚本,比如需要每30分钟运行一次脚本script1,打开system-Scheduler菜单,设置如下图: