找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 8005|回复: 6

[脚本] pcc多线PPPOE拔号,灰太狼版主帮我修改的自动寻找默认端口5.X的DDNS

[复制链接]
发表于 2012-3-1 12:39:13 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 kzyfl 于 2012-3-1 12:40 编辑

原来在3.30下十分好用,就是在5.12版下不能用了,升级到5.12和以前的3.30版的ros的设置都完全一样,就是DDNS用不了,以下是灰太狼版主帮我修改后的5.12版的DDNS脚本。个人感觉灰太狼版主改的也没错,就是在5.12下用不了,不知道为什么,希望高手能给指点指点。

:global ddnsuser "用户名"
:global ddnspass "密码"
:global ddnshost "二级域名"
:global ddnsinterface [/ip route get [/ip route find static=yes active=yes] gateway]
:set ddnsinterface [/ip address get [/ip address find network=$ddnsinterface dynamic=yes] interface]
:global ddnslastip
:put $ddnsinterface
: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
  }
}



以下是以前论坛上可用的3.30脚本。
: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
  }
}
routeros
发表于 2012-3-1 14:38:51 | 显示全部楼层
本帖最后由 host2318 于 2012-3-1 14:41 编辑

v5.x
:global ddnsinterface [/ip route get [/ip route find static=yes active=yes] gateway]
:set ddnsinterface [/ip address get [/ip address find network=$ddnsinterface dynamic=yes] interface]
v3.x
:global ddnsinterface [/ip route get [/ip route find dynamic=yes static=yes active=yes ] interface]



3.30下ip route菜单内有 interface 列
5.X取消了那一列内容。所以获取不到interface这个参数,而版主改为获取网关地址,再通过网关地址拿到ip address菜单内的interface

思路灵活,运用巧妙。之前折腾过,也没弄出来自动的

适用于所有环境,实在是方便!
routeros
回复

使用道具 举报

 楼主| 发表于 2012-3-1 14:54:33 | 显示全部楼层
本帖最后由 kzyfl 于 2012-3-2 00:15 编辑


适应所有环境,就是不适应我这边环境,我这边是很多PPPOE拔号的IP地址的网关地址一样。



routeros
回复

使用道具 举报

 楼主| 发表于 2012-3-2 00:16:32 | 显示全部楼层
host2318 发表于 2012-3-1 14:38
v5.x
:global ddnsinterface [/ip route get [/ip route find static=yes active=yes] gateway]
:set ddn ...

我试过了,多IP,网关不重的话,可以正常DDNS,如果多IP,网关重复的话,总是DDNS不成功。
routeros
回复

使用道具 举报

发表于 2012-3-2 09:52:35 | 显示全部楼层
本帖最后由 host2318 于 2012-3-2 09:53 编辑
kzyfl 发表于 2012-3-2 00:16
我试过了,多IP,网关不重的话,可以正常DDNS,如果多IP,网关重复的话,总是DDNS不成功。


那就试试changeip给的脚本吧。也是全自动,也不用你选择什么的。工作原理不同了
http://www.changeip.com/mikrotik/

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

  5. # Set your specific ChangeIP.com preferences here.
  6. :global ddnsuser "user"
  7. :global ddnspass "password"
  8. :global ddnshost "MyRouterHostname.example.org"
  9. # Change ddnsport to 8245 to bypass proxy.
  10. :local ddnsport 80

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

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

  15. :log info "DDNS: Starting."

  16. # Initialize checkpoint
  17. :global ddnscheckpoint
  18. :if ([:typeof $ddnscheckpoint] = "time") do={
  19.         :log info ("DDNS: Last check was " . ([/system clock get time] - $ddnscheckpoint))
  20. } else={
  21.         :log info "DDNS: Cannot determine checkpoint, set now."
  22.         :global ddnscheckpoint ( [/system clock get time] - 1d )
  23. }

  24. # Get the current IP
  25. :if ([/system clock get time] - $ddnscheckpoint > [:totime 180s] || [/system clock get time] - $ddnscheckpoint < [:totime 0s]) do={
  26.    :log info "DDNS: Performing remote IP detection."
  27.    /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
  28.    :global ddnscheckpoint [/system clock get time]
  29. } else={
  30.    :log info "DDNS: Please be considerate and wait a few seconds longer."
  31.    :break
  32. }

  33. # Parse the IP address received from fetch script.
  34.         :global ddnslastip
  35.         :local html [/file get "ip.changeip.com.txt" contents]
  36.         :local ddnsip [:pick $html ([:find $html "<!--IPADDR="] + 11) [:find $html "-->"] ]

  37. # Is it a valid IP and is it different than the last one?
  38.         :if ([:typeof [:toip $ddnsip]] = "ip" AND $ddnsip != $ddnslastip ) do={
  39.                 :log info "DDNS: Sending UPDATE with $ddnsip"
  40.                 :log info [/tool dns-update name=$ddnshost address=$ddnsip key-name=$ddnsuser key=$ddnspass ]
  41.                 :global ddnslastip $ddnsip
  42.         } else={
  43.                 :log info "DDNS: No update required."
  44.         }
  45. }

复制代码
routeros
回复

使用道具 举报

 楼主| 发表于 2012-3-2 16:31:19 | 显示全部楼层
host2318 发表于 2012-3-2 09:52
那就试试changeip给的脚本吧。也是全自动,也不用你选择什么的。工作原理不同了
http://www.changeip. ...

这个脚本很不错,问题解决。
routeros
回复

使用道具 举报

发表于 2013-3-20 22:23:05 | 显示全部楼层
不错 解决5x的 ddns!
routeros
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-23 19:11 , Processed in 0.052199 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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