Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2880605
  • 博文数量: 471
  • 博客积分: 10012
  • 博客等级: 上将
  • 技术积分: 5255
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-10 23:58
文章分类

全部博文(471)

文章存档

2011年(3)

2010年(61)

2009年(52)

2008年(212)

2007年(69)

2006年(74)

我的朋友

分类: LINUX

2010-04-13 08:51:30

3.xx版自动端口映射

  1. {
  2. #bbs.routerclub.com ID=bh
  3. :local poe "pppoe-out4";
  4. /interface pppoe-client;
  5. monitor $poe once do={
  6. :if ($status="connected") do={
  7. :if ($uptime<00:05:00) do={
  8. :local newIP [/ip address get [/ip address find interface=$poe dynamic=yes] address];
  9. :set newIP [:pick $newIP 0 [:find $newIP "/"]];
  10. :put $newIP;
  11. :local oldIP [/ip fir nat get [/ip fir nat find comment="adsl4_80"] dst-address];
  12. :if ($newIP!=$oldIP) do={
  13. :log info [/ip fir nat set [/ip firewall nat find comment="adsl4_80"] dst-address=$newIP];
  14. :log info ( "adsl4_IP=" . $newIP . " 〖adsl4映射到80端口修改完毕〗");
  15. }}}}}
复制代码
3.xx版自动端口映射  已在3.20版运行正常,此脚本是根据“47771885”兄的另一脚本修改而来,在此表示感谢!

{
#bbs.routerclub.com ID=bh此为作者备注
:local poe "pppoe-out4";定义需要判断的接口
/interface pppoe-client;
monitor $poe once do={
:if ($status="connected") do={宽带为连接状态时 向下执行脚本
:if ($uptime<00:05:00) do={定义接口连接上多少时间内操作 根据脚本运行间隔时间修改
:local newIP [/ip address get [/ip address find interface=$poe dynamic=yes] address];
:set newIP [:pick $newIP 0 [:find $newIP "/"]];截取指定接口拨号获得的新IP
:put $newIP;
:local oldIP [/ip fir nat get [/ip fir nat find comment="adsl4_80"] dst-address];获取原设映射的旧IP
:if ($newIP!=$oldIP) do={如果新旧IP不相同
:log info [/ip fir nat set [/ip firewall nat find comment="adsl4_80"] dst-address=$newIP];自动填入新IP
:log info ( "adsl4_IP=" . $newIP . " 〖adsl4映射到80端口修改完毕〗");
}}}}}

------------------------------------------------分割线--------------------------------------------------------------
附上2.927版自动端口映射

:global ip [ /ip address get [/ip address find interface=pppoe-out4] address ]
:global new-ip [:pick $ip 0 [:find $ip "/"]]
:global old-ip [/ip fir nat get [/ip fir nat find comment="adsl4_80"] dst-address]
:if ($new-ip != $old-ip) do={
        :log info [/ip fir nat set [/ip firewall nat find comment="adsl4_80"] dst-address=$new-ip]
        :log info "〖adsl4映射到80修改完毕〗"
}

搞出3.xx版,是因为不会把这个2.927版修改成3.xx版,所以另走捷径,呵呵
请问高人该如何改?
阅读(1694) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~