找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3643|回复: 2

[脚本] 非常巧妙的脚本,哪位大侠能说说原理是啥。

[复制链接]
发表于 2012-3-2 20:40:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
本帖最后由 kzyfl 于 2012-3-2 20:43 编辑

以下是PPPOE多线ddns脚本,(ros5.X)非常好用。就是不知道原理是啥,哪位大侠能帮解释解释。
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 \"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"

/system scheduler
add comment="ChangeIP.com Dynamic DNS Update" \
  disabled=no \
  interval=5m name=DynamicDNS \
  on-event=HomingBeacon \
  policy=read,write start-time=startup
routeros
发表于 2012-3-2 21:42:12 | 显示全部楼层
这个应该是通过 changeip 自己的一个页面来检测你访问过来的IP. 悲剧的是我这个垃圾的运营商会在对外访问时将我端口的公网地址NAT成另外一个公网地址, 此举本来应该是为了限制P2P的, 却也顺便把这个DDNS脚本给封了. 3.x时代好用的脚本5.x又不能用, 我现在正头疼这个呢
routeros
回复

使用道具 举报

发表于 2012-3-2 22:08:43 | 显示全部楼层
运营商会在对外访问时将我端口的公网地址NAT成另外一个公网地址, 此举本来应该是为了限制P2P的, 却也顺便把这个DDNS脚本给封了
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-11-24 09:22 , Processed in 0.063488 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表