分类: LINUX
2010-04-13 08:51:30
{ #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版,所以另走捷径,呵呵 请问高人该如何改? |