|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
本帖最后由 host2318 于 2011-11-14 23:50 编辑
没在使用2.9.X的了。所以。。。
注意事项:
1.ip dns set里面必须设置DNS服务器IP
2.域名解析需要时间生效,数十秒到几分钟不等
3.域名解析调度时间间隔建议5分钟以上(changeip有设置更新频率过高加入黑名单的,好像是5分钟解析300次的!)
4.start time 是可以设置为开机即启动的。。。。
测试过5.6可用的PPPOE拨号
- :local ddnsuser "用户"
- :local ddnspass "密码"
- :local theinterface "端口"
- :local ddnshost "域名"
- :local ipddns [:resolve $ddnshost];
- :local ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
- :if ([ :typeof $ipfresh ] = nil ) do={
- :log info ("DynDNS: No ip address on $theinterface .")
- } else={
- :for i from=( [:len $ipfresh] - 1) to=0 do={
- :if ( [:pick $ipfresh $i] = "/") do={
- :set ipfresh [:pick $ipfresh 0 $i];
- }
- }
-
- :if ($ipddns != $ipfresh) do={
- :log info ("DynDNS: IP-DynDNS = $ipddns")
- :log info ("DynDNS: IP-Fresh = $ipfresh")
- :log info "DynDNS: Update IP needed, Sending UPDATE...!"
- :log info [ /tool dns-update name=$ddnshost address=$ipfresh key-name=$ddnsuser key=$ddnspass ]
- :global ipddns $ipfresh
- :log info "DynDNS: IP updated to $ipfresh!"
- } else={
- :log info "DynDNS: dont need changes";
- }
- }
复制代码 固定IP3.30,自动识别端口,不需要指定.已测试,可用
- :global ddnsuser "用户"
- :global ddnspass "密码"
- :global ddnshost "域名"
- :global ddnsip
- :global ddnslastip
- :if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
- :global ddnsinterface
- :global ddnssystem ("mt-" . [/system package get system version] )
- :local int
- :foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
- :if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
- :global ddnsinterface [/ip route get $int interface]
- }
- }
- :global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
- :if ([ :typeof $ddnsip ] = nil ) do={
- :log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
- } else={
- :if ($ddnsip != $ddnslastip) do={
- :log info ("DDNS: IP-CHANGEIP = $ddnslastip")
- :log info ("DDNS: IP-Fresh = $ddnsip")
- :log info "DDNS: Update IP needed, 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: dont need changes"
- }
- }
- #end
复制代码 pppoe拨号,自动获取默认路由的端口,版本运行待考证
- :global ddnsuser "用户名"
- :global ddnspass "密码"
- :global ddnshost "你的域名"
- :global ddnsinterface [/ip route get [/ip route find dynamic=yes static=yes active=yes] interface]
- :global ddnslastip
- :global ddnsip [ /ip address get [/ip address find dynamic=yes interface=$ddnsinterface ] address ]
- :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 [ /tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ]
- :global ddnslastip $ddnsip
- }
- }
复制代码 多线PPPOE更新IP(每条线路都有域名,这样即使不指定哪条线进,哪条线回。也不怕默认路由改变导致不能登录了)
X 的值,就是线路数。域名格式为 name1.3-a.net name2.3-a.net.在域名前缀输入对应的域名前缀,不含数字
- :local ddnsuser "用户"
- :local ddnspass "密码"
- :local status
- :local x
- :set x 2
- :for i from=1 to=$x do={
- :local status [/interface get [/interface find name=("pppoe-out" . $i)] running]
- :if ($status!=true) do={
- :set i ($i+1)}
- :local ddnsinterface ("pppoe-out" . $i)
- :local ddnshost ("域名前缀". $i .".3-a.net")
- :local ddnslastip [:resolve $ddnshost]
- :if ([ :typeof $ddnslastip ] = nil ) do={ :local ddnslastip "0" }
- :local ddnsiph [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
- :local ddnsip [:pick $ddnsiph 0 [:find $ddnsiph "/"]]
- :if ($ddnsip != $ddnslastip) do={
- /tool dns-update name=$ddnshost address=$ddnsip key-name=$ddnsuser key=$ddnspass
- :log info ( $ddnshost . " Sending UPDATE!")
- }
- }
复制代码 |
|