kzyfl 发表于 2012-4-16 13:17:34

从5.12升级到5.14以后就悲剧了.

ROS 5.12的DDNS还可以用,升级到5.14后就不能用了.附DDNS脚本


# HomingBeacon Main Dynamic DNS Update Script
# Written by Sam Norris, ChangeIP.com
# 20100728 Tested on RouterOS 4.9
# 20110511 Tested on RouterOS 5.2

# Set your specific ChangeIP.com preferences here.
:global ddnsuser "hnlt001"
:global ddnspass "*****"
:global ddnshost "*****.mrface.com"
# Change ddnsport to 8245 to bypass proxy.
:local ddnsport 80

# Do not edit anything below this line.You have been warned.
# Abusive updates to the system will cause firewall blocks.

# Please be considerate and
# do not let this script run more than once per 3-5 minutes.

:log info "DDNS: Starting."

# Initialize checkpoint
:global ddnscheckpoint
:if ([:typeof $ddnscheckpoint] = "time") do={
        :log info ("DDNS: Last check was " . ( - $ddnscheckpoint))
} else={
        :log info "DDNS: Cannot determine checkpoint, set now."
        :global ddnscheckpoint ( - 1d )
}

# Get the current IP
:if ( - $ddnscheckpoint > [:totime 180s] || - $ddnscheckpoint < [:totime 0s]) do={
   :log info "DDNS: Performing remote IP detection."
   /tool fetch address="ip.changeip.com" host="ip.changeip.com" src-path=("/?" . ) dst-path="ip.changeip.com.txt" mode=http port=$ddnsport
   :global ddnscheckpoint
} else={
   :log info "DDNS: Please be considerate and wait a few seconds longer."
   :break
}

# Parse the IP address received from fetch script.
        :global ddnslastip
        :local html
        :local ddnsip [:pick $html ([:find $html "<!--IPADDR="] + 11) [:find $html "-->"] ]

# Is it a valid IP and is it different than the last one?
        :if ([:typeof [:toip $ddnsip]] = "ip" AND $ddnsip != $ddnslastip ) do={
                :log info "DDNS: Sending UPDATE with $ddnsip"
                :log info
                :global ddnslastip $ddnsip
        } else={
                :log info "DDNS: No update required."
        }
}

xingyu612 发表于 2012-4-16 13:25:43

ros 5.xDDNS changeip最新脚本!适合ADSL多线,掉线自动切换IP!Open a terminal window and paste both scripts below.
Then using the script window change the UserID, Password, and hostname.

/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 \"用户ID\"\r\
    \n:global ddnspass \"密码\"\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 \" . ( - \$d\
    dnscheckpoint))\r\
    \n} else={\r\
    \n\t:log info \"DDNS: Cannot determine checkpoint, set now.\"\r\
    \n\t:global ddnscheckpoint ( - 1d )\r\
    \n}\r\
    \n\r\
    \n# Get the current IP\r\
    \n:if ( - \$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=(\"/\?\" . ) dst-path=\"ip.changeip.com.\
    txt\" mode=http port=\$ddnsport\r\
    \n   :global ddnscheckpoint \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 \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"

/system scheduler
add comment="ChangeIP.com Dynamic DNS Update" \
disabled=no \
interval=5m name=DynamicDNS \
on-event=HomingBeacon \
policy=read,write start-time=startup

xingyu612 发表于 2012-4-16 13:26:29

我现在就是用的5.14版本!

kzyfl 发表于 2012-4-16 13:27:41

xingyu612 发表于 2012-4-16 13:26 static/image/common/back.gif
我现在就是用的5.14版本!

是单线还是多线,固定IP还是PPPOE拔号,能否DDNS

xingyu612 发表于 2012-4-16 13:29:50

双线ADSLPPPOE,可以DDNS

kzyfl 发表于 2012-4-16 13:35:30

xingyu612 发表于 2012-4-16 13:29 static/image/common/back.gif
双线ADSLPPPOE,可以DDNS

你的DDNS脚本,是不是只能在外网不同网关下才能使用,如果外线同网关就不能使用,能否亮出来参考参考

FreeBSD_shell 发表于 2012-4-16 13:35:41

靠,现在还有人用这脚本!用了3.30以上的都不用这些了,都是一条命令搞定
实在很无语

FreeBSD_shell 发表于 2012-4-16 13:37:05

DDNS 掉线自动切换都是一条命令就搞定的事情,还搞得那么麻烦
看来你们都不去了解新功能
我有时连接PCC都直接在路由上动了!

kzyfl 发表于 2012-4-16 13:38:56

FreeBSD_shell 发表于 2012-4-16 13:35 static/image/common/back.gif
靠,现在还有人用这脚本!用了3.30以上的都不用这些了,都是一条命令搞定
实在很无语

不知道啥命令,能否给指点一下,这边环境,多线PPPOE,外线网关地址相同.

FreeBSD_shell 发表于 2012-4-16 13:42:51

你可以到我的帖子里面找一下!里面有一些快速设置的脚本与命令
不用你这里这样设置得这么麻烦

kzyfl 发表于 2012-4-16 13:45:15

FreeBSD_shell 发表于 2012-4-16 13:42 static/image/common/back.gif
你可以到我的帖子里面找一下!里面有一些快速设置的脚本与命令
不用你这里这样设置得这么麻烦

好,谢谢了.

jacky_rose 发表于 2012-10-23 22:35:38

貌似直接 一句就搞定了? /tool dns-update name=域名 address=127.0.0.255 key-name=账号 key=密码

jacky_rose 发表于 2012-10-23 22:36:18

xingyu612 发表于 2012-4-16 13:25 static/image/common/back.gif
ros 5.xDDNS changeip最新脚本!适合ADSL多线,掉线自动切换IP!

/tool dns-update name=域名 address=127.0.0.255 key-name=账号 key=密码
页: [1]
查看完整版本: 从5.12升级到5.14以后就悲剧了.