|
:global count X
#这里定义的为adsl拨号的数目
:global runid
:global status
:global ddnsinterface "pppoe-out"
#这里定义通用的adsl名次,这里为pppoe-out1这样的形式
:set runid ("a")
:for i from=1 to=$count do={
:set status [/interface get [/interface find name=("pppoe-out" . $i) ] running ]
:if ($status=true) do={:set runid ($runid . $i )
}
}
:set runid [:pick $runid 1 2]
#获得第一条已经成功连接的ADSL
:set ddnsinterface ($ddnsinterface . $runid)
:global ddnsuser "********"
:global ddnspass "********"
:global ddnshost "******.changeip.net"
:global ddnsip
:global ddnsipfn
:global ddnslastip [:tostr [:resolve $ddnshost] ]
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
:global ddnssystem ("mt-" . [/system package get system version] )
:local ddnsipfn [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
:global ddnsip [:pick $ddnsipfn 0 [:find $ddnsipfn "/" ] ]
:if ([ :typeof $ddnsip ] = nil ) do={
:log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={
:if ($ddnsip != $ddnslastip) do={
:log warning ("发送DDNS更新!" . "接口为:" . $ddnsinterface)
:log info [ :put [/tool dns-update name=$ddnshost address=$ddnsip key-name=$ddnsuser key=$ddnspass ] ]
:global ddnslastip $ddnsip
} else={
:log info "DDNS: No update required."
}
}
|
|