|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
×
本帖最后由 host2318 于 2013-4-10 22:06 编辑
changeip本身相当靠谱,出现故障可能是地域性问题,或者操作不当引起
changeip有限制同一个域名更新频率。如果单位时间内,更新次数太多,这个域名会被拉黑名单,导致更新不到
解决的办法很简单,在计划任务内设置间隔时间长一点即可。
并附DDNS更新脚本两个。分别用于更新V3.X和V4&V5版本的。都是全自动的,不需要设置接口,会自动侦测默认路由的接口
3.x的脚本不知道是哪位编写的
V4&V5的脚本是changeip官方提供的,下载地址“http://www.changeip.com/mikrotik/”
V3.X脚本如下
- :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 "\BF\AA\CA\BC\B8\FC\D0\C2\D4\B6\B3\CC\D3\F2\C3\FB"
- :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 "ip\B5\D8\D6\B7\CE\DE\B1\E4\BB\AF,\D3\F2\C3\FB\B2\BB\D3\C3\B8\FC\D0\C2"
- }
- }
- #end
复制代码 V4&V5脚本如下- /system script
- add name=HomingBeacon policy=\
- ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api \
- source="# HomingBeacon Main Dynamic DNS Update Script\r\
- \n# Written by Sam Norris, ChangeIP.com\r\
- \n# 20100728 Tested on routeros 4.9\r\
- \n# 20110511 Tested on RouterOS 5.2\r\
- \n\r\
- \n# Set your specific ChangeIP.com preferences here.\r\
- \n:global ddnsuser "USERID"\r\
- \n:global ddnspass "PASSWORD"\r\
- \n:global ddnshost "HOSTNAME.changeip.net"\r\
- \n# Change ddnsport to 8245 to bypass proxy.\r\
- \n:local ddnsport 80\r\
- \n\r\
- \n# Do not edit anything below this line. You have been warned.\r\
- \n# Abusive updates to the system will cause firewall blocks.\r\
- \n\r\
- \n# Please be considerate and\r\
- \n# do not let this script run more than once per 3-5 minutes.\r\
- \n\r\
- \n:log info "DDNS: Starting."\r\
- \n\r\
- \n# Initialize checkpoint\r\
- \n:global ddnscheckpoint\r\
- \n:if ([:typeof \$ddnscheckpoint] = "time") do={\r\
- \n\t:log info ("DDNS: Last check was " . ([/system clock get time] - \$d\
- dnscheckpoint))\r\
- \n} else={\r\
- \n\t:log info "DDNS: Cannot determine checkpoint, set now."\r\
- \n\t:global ddnscheckpoint ( [/system clock get time] - 1d )\r\
- \n}\r\
- \n\r\
- \n# Get the current IP\r\
- \n:if ([/system clock get time] - \$ddnscheckpoint > [:totime 180s] || [/s\
- ystem clock get time] - \$ddnscheckpoint < [:totime 0s]) do={\r\
- \n :log info "DDNS: Performing remote IP detection."\r\
- \n /tool fetch address="ip.changeip.com" host="ip.changeip.com" src-\
- path=("/\?" . [/int eth get 0 mac-address ]) dst-path="ip.changeip.com.\
- txt" mode=http port=\$ddnsport\r\
- \n :global ddnscheckpoint [/system clock get time]\r\
- \n} else={\r\
- \n :log info "DDNS: Please be considerate and wait a few seconds longer\
- ."\r\
- \n :break\r\
- \n}\r\
- \n\r\
- \n# Parse the IP address received from fetch script.\r\
- \n\t:global ddnslastip\r\
- \n\t:local html [/file get "ip.changeip.com.txt" contents]\r\
- \n\t:local ddnsip [:pick \$html ([:find \$html "<!--IPADDR="] + 11) [:fi\
- nd \$html "-->"] ]\r\
- \n\r\
- \n# Is it a valid IP and is it different than the last one\?\r\
- \n\t:if ([:typeof [:toip \$ddnsip]] = "ip" AND \$ddnsip != \$ddnslastip \
- ) do={\r\
- \n\t\t:log info "DDNS: Sending UPDATE with \$ddnsip"\r\
- \n\t\t:log info [/tool dns-update name=\$ddnshost address=\$ddnsip key-nam\
- e=\$ddnsuser key=\$ddnspass ]\r\
- \n\t\t:global ddnslastip \$ddnsip\r\
- \n\t} else={\r\
- \n\t\t:log info "DDNS: No update required."\r\
- \n\t}\r\
- \n}\r\
- \n"
复制代码 |
|