ADSL DDNS自动更新脚本!
# jul/01/2007 18:46:37 by RouterOS 2.9.27
# software id = 2WP1-T9T
#
/ system script
add name="ddnsInit" source="\n:log info \"ddnsInit: Creating Dynamic DNS \
update system.\"\n:global u \"账户\"\n:global p \"密码\"\n:global n \
\"cnfug\"\n:global z \"25u.com\"\n:global dialInterface \[/interface \
pppoe-client get pppoe-out name\]\n:log info \(\"find dial interface: \" . \
\$dialInterface\)\n:global ac \[/ip address get \[/ip address find \
interface=\$dialInterface\] address\]\n:global a \[:pick \$ac 0 \[:find \
\$ac \"/\"\]\]\n" policy=ftp,reboot,read,write,policy,test,winbox,password
add name="ddnsSendUpdate" source="\n:log info \(\"ddnsSendUpdate: External IP \
Address is \" . \$a\)\n/tool dns-update name=\$n zone=\$z address=\$a \
key-name=\$u key=\$p\n
\n/ip fir nat set\[/ip firewall nat find \
comment=\"ADSL\"\] dst-address=\$a" \
policy=ftp,reboot,read,write,policy,test,winbox,password
add name="ddnsCheck" source="\n:if \(\[/system scheduler get ddnsJob \
run-count\]<=1\) do={\n/system script run ddnsInit\n/system script run \
ddnsSendUpdate\n/system scheduler enable ddnsRetry\n}\n:global temp \
\$ac\n:global b \[/ip address get \[/ip address find \
interface=\$dialInterface\] address\]\n:if \(\$temp != \$b\) do={\n:global \
ac \$b\n:global a \[:pick \$ac 0 \[:find \$ac \"/\"\]\]\n:log info \
\(\"ddnsCheck: Found new IP address: \" . \$a\)\n/system script run \
ddnsSendUpdate\n}\n" \
policy=ftp,reboot,read,write,policy,test,winbox,password
add name="ddnsReset" source="\n/system scheduler remove ddnsJob\n/system \
scheduler add name=ddnsJob interval=30s on-event=ddnsCheck\n:global \
u\n:global p\n:global n\n:global z\n:global dhcpInterface\n:global \
a\n:global ac\n:global b\n:global temp\n" \
policy=ftp,reboot,read,write,policy,test,winbox,password
add name="ddnsApp" source="\n:if \(\(\[:resolve \(\$n . \".\" . \$z\)\]\) != \
\$a\) do={\n/system script run ddnsSendUpdate\n}\n" \
policy=ftp,reboot,read,write,policy,test,winbox,password
/ system scheduler
add name="ddnsRetry" on-event=ddnsApp start-date=apr/03/2007 \
start-time=23:28:22 interval=30m comment="" disabled=no
add name="ddnsJob" on-event=ddnsCheck start-date=jul/01/2007 \
start-time=18:14:29 interval=30s comment="" disabled=no
如果出现ddns error timeout ,让这个IP 204.16.170.0/24通过就行了 另外注意红色部分
上面的代码绝对没有任何问题~
[ 本帖最后由 cnfug 于 2007-7-1 18:58 编辑 ] 太复杂了,ddns用得到这么复杂么?
帮你顶先
页:
[1]