|  | 
 
 发表于 2008-9-7 16:20:38
|
显示全部楼层 
| 原帖由 javen520 于 2006-6-18 19:44 发表 动态的我倒还没现实做过~`
 
 不过却可以使用脚本 Script 来动态更新 IP ~~`
 
 而且你的路由器一连上 ADSL 就会获取一个 IP ~`你可以将他看成是固定 IP ~`
 
 然后做个脚本~` 监视 ADSL 的 IP ~`只要重新连接发生 I ...
这个说法是对的.我看了很多下面写的方法,我想问你们有没有做过,不要在网上COPY过来加分就好.
 我只想更正一下."监视 ADSL 的 IP ~`只要重新连接发生"这样做不好.你监视多常时间监视一次.如果在你监视的时间内以重新连接好,那无法做到你想要的要求了.
 小弟有一个方法
 映谢可以用脚本建立删除修改.当我用修改好了.在一定的时间内不理ADSL外网IP有没有变,对映射进行修改.这样不用去监视ADSL.我个我不是说说.我是动手做过.常期时间下成功
 我先把网上的做法COPY出来.
 1.端口映射:
 winbox中
 system->scripts中添加名字为add-nat,内容如下:
 
 #script add-nat
 :log info "Add-Nat: Sending Dynamic NAT  update  Begin"
 /ip firewall nat add chain=dstnat dst-address=[ /ip address get [/ip address find interface=pppoe-out] address ] protocol=tcp dst-port=80 action=dst-nat to-addresses=192.168.0.57 to-ports=80 comment="WEB"
 /ip firewall nat add chain=dstnat dst-address=[ /ip address get [/ip address find interface=pppoe-out] address ] protocol=tcp dst-port=110 action=dst-nat to-addresses=192.168.0.57 to-ports=110 comment="
  OP" /ip firewall nat add chain=dstnat dst-address=[ /ip address get [/ip address find interface=pppoe-out] address ]  protocol=tcp dst-port=25 action=dst-nat to-addresses=192.168.0.57 to-ports=25 comment="SMTP"
 :log info "Add-Nat: Sending Dynamic NAT  update  End Sucess!!!"
 #script remove-nat
 :log info "remove when ip is down"
 /ip firewall nat remove WEB
 /ip firewall nat remove POP
 /ip firewall nat remove SMTP
 /ip firewall nat remove cxhemule
 :log info "remove sucessful!!!"
 端口映射:
 winbox中
 system->scripts中添加名字为remove-nat,内容如下:
 
 
 
 #script remove-nat
 
 :log info "remove when ip is down"
 
 /ip firewall nat remove WEB
 /ip firewall nat remove POP
 /ip firewall nat remove SMTP
 
 :log info "remove sucessful!!!"
 
 
 
 添加好以上2个脚本后,在 tools->netwatch里面
 host:填你当地的dns服务器
 interval:00:01:00
 timeout:1000ms
 
 up:add-nat
 down:remove-nat
 
 填好以后,就开始每interval时间测试该IP是否连通,如果由up->down就执行remove-nat,由down->up就执行add-nat
 
 
 2.更新DDNS
 去www.changeip.com申请个免费DDNS
 
 
 winbox中
 system->scripts中添加名字为DDNSUP,内容如下:
 
 
 
 
 :log info "DDNS: Begin"
 
 :global ddns-user "登陆changeip的帐号"
 :global ddns-pass "密码"
 :global ddns-host "*1"
 :global ddns-interface "pppoe拨号的interface我的是pppoe-out"
 
 :global ddns-system ("mt-" . [/system package get [/system package find name=system] version] )
 
 :global ddns-ip [ /ip address get [/ip address find interface=$ddns-interface] address ]
 
 :if ([ :typeof $ddns-lastip ] = nil ) do={ :global ddns-lastip 0.0.0.0/0 }
 
 :if ([ :typeof $ddns-ip ] = nil ) do={
 
 :log info ("DDNS: No ip address present on " . $ddns-interface . ", please check.")
 
 } else={
 
 :if ($ddns-ip != $ddns-lastip) do={
 
 :log info "DDNS: Sending Update!"
 :log info [ /tool dns-update name=$ddns-host address=[:pick $ddns-ip 0 [:find $ddns-ip "/"] ] key-name=$ddns-user key=$ddns-pass ]
 :global ddns-lastip $ddns-ip
 
 } else={
 
 :log info "DDNS: No change"
 
 }
 
 }
 
 :log info "DDNS: End"
 
 
 
 
 
 在system->scheduler里面添加:
 
 
 name:ddnsrun
 interval:00:30:00
 on event
  DNSUP 
 
 
 OK,interval:00:30:00 表示30分钟执行一次
 on event
  DNSUP表示执行DDNSUP这个脚本 以上是网络上的资料
 我做了修改
 就是不去监视外网是否断线.
 不理是否断线了,每多长时间修改一次端口映射就可以了.
 怎么做想一想
 也可以加我的QQ:88420649
 | 
 |