找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3813|回复: 2

[其它] 3.xx版自动端口映射 顺便请47771885兄进入

[复制链接]
发表于 2010-4-13 04:59:43 | 显示全部楼层 |阅读模式

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

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

×
  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版,所以另走捷径,呵呵
请问高人该如何改?
routeros
发表于 2010-4-13 09:47:33 | 显示全部楼层
本帖最后由 47771885 于 2010-4-13 09:59 编辑

多谢楼上兄弟支持..... 我不是高人 一米七都不到
如果你做映射的话 直接选 接口就好了啊
至于你的这个脚本
吧变量名的- 减号去掉就可以 了
终端运行不支持 直接使用中文 或其他 特殊字符
  1. {
  2. :local ip [ /ip address get [/ip address find interface=pppoe-out4] address ]
  3. :local newip [:pick $ip 0 [:find $ip "/"]]
  4. :local oldip [/ip fir nat get [/ip fir nat find comment="adsl4_80"] dst-address]
  5. :if ($newip != $oldip) do={
  6. :log info [/ip fir nat set [/ip firewall nat find comment="adsl4_80"] dst-address=$newip]
  7. :log info "\A1\BCadsl4\D3\B3\C9\E4\B5\BD80\D0\DE\B8\C4\CD\EA\B1\CF\A1\BD"
  8. }}
复制代码
未做详测 有问题 请再说
routeros
回复

使用道具 举报

发表于 2010-4-28 08:01:09 | 显示全部楼层
还不太会这些~~~
routeros
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-16 04:02 , Processed in 0.046020 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

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