ROS软路由论坛 ROSABC.com 网络方案网络工程交流

 找回密码
 会员注册

QQ登录

只需一步,快速开始

查看: 6449|回复: 1

[交流] ROS软路由 3.x 2线nth脚本

[复制链接]
发表于 2008-2-23 08:06:53 | 显示全部楼层 |阅读模式

马上注册成为ROSABC会员,随时发帖回复。

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

x
/interface set [/interface find name=ether1] name=wan1
/interface set [/interface find name=ether2] name=wan2
/interface set [/interface find name=ether3] name=lan
/interface pppoe-client add name="pppoe-out1" max-mtu=1480 max-mru=1480 interface=wan1 user="user" password="1234" profile=default service-name="" ac-name="" add-default-route=no dial-on-demand=no use-peer-dns=no allow=pap,chap,mschap1,mschap2 disabled=no
/interface pppoe-client add name="pppoe-out2" max-mtu=1480 max-mru=1480 interface=wan2 user="user2" password="1234" profile=default service-name="" ac-name="" add-default-route=no dial-on-demand=no use-peer-dns=no allow=pap,chap,mschap1,mschap2 disabled=no
/ip address add address=10.111.1.1/24 comment=1 interface=pppoe-out1
/ip address add address=10.112.1.1/24 comment=2 interface=pppoe-out2
/ip address add address=192.168.1.1/24 interface=lan

/system scheduler add name=schedule2 on-event=":global assignrn:global newrn:global statusrn:global xrn:global linkrn:set x 2rn:set link 3rn:for i from=1 to=$x do={rn :set status [/interface get [/interface find name=("pppoe-out" . $i)] running]rn :if ($status=true) do={rn :set new [/ip address get [/ip address find dynamic=yes interface=("pppoe-out" . $i)] address]rn :set new [:pick $new 0 ([:len $new] -3)]rn :set assign [/ip address get [/ip address find dynamic=no interface=("pppoe-out" . $i)] address]rn :set assign [:pick $assign 0 ([:len $assign] -3)]rn :if ($assign != $new) do={ /ip address set [/ip address find comment=$i] address=$new network=$new broadcast=$newrn /ip fir nat set [/ip fir nat find comment=$i] to-addresses=$newrn /ip route set [/ip route find comment=$i] gateway=$newrn :if ($i=1) do={/ip route set [/ip route find comment=$link] gateway=$new}rn }rn }rn}rn" interval=5
/ip route add dst-address=0.0.0.0/0 gateway=10.111.0.1 routing-mark=1 comment=1 disabled=no
/ip route add dst-address=0.0.0.0/0 gateway=10.112.0.1 routing-mark=2 comment=2 disabled=no
/ip route add dst-address=0.0.0.0/0 gateway=10.111.0.1 comment=3 disabled=no
/ip firewall nat add chain=srcnat action=masquerade out-interface=pppoe-out1
/ip firewall nat add chain=srcnat action=masquerade out-interface=pppoe-out2
/ip firewall mangle add chain=prerouting action=mark-connection new-connection-mark=1 passthrough=yes connection-state=new src-address=192.168.1.2-192.168.1.254 nth=2,1
/ip firewall mangle add chain=prerouting action=mark-routing new-routing-mark=1 passthrough=yes src-address=192.168.1.2-192.168.1.254 connection-mark=1
/ip firewall mangle add chain=prerouting action=mark-connection new-connection-mark=2 passthrough=yes connection-state=new src-address=192.168.1.2-192.168.1.254 nth=2,2
/ip firewall mangle add chain=prerouting action=mark-routing new-routing-mark=2 passthrough=yes src-address=192.168.1.2-192.168.1.254 connection-mark=2
发表于 2008-2-27 18:30:22 | 显示全部楼层
本帖最后由 younot 于 2009-11-24 23:13 编辑

请在telnet方式下输入。或是winbox的New Terminal方式下输入。放到scripts中运行会引起comment参数丢失。
自行修改第五行、第八行处的用户名和密码。

IP段从192.168.1.2-254之间如有疑问请留言。
因没有做dhcp部份脚本,必需得手动设置本电脑IP为192.168.1.2-254
网关为192.168.1.1
dns根据自己本地情况自己设。
您需要登录后才可以回帖 登录 | 会员注册

本版积分规则

不良信息举报Q:2000617

软路由

不良信息举报Q:2000617|Archiver|ROS软路由论坛 ROSABC.com 网络方案网络工程交流

GMT+8, 2025-8-4 22:42 , Processed in 0.099318 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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