ROS单线多拨pppoe

#设置内网IP地址
/ ip add add interface=ether1 address=192.168.0.254/255.255.255.0
#设置共享上网
/ ip firewall nat add action=masquerade chain=srcnat src-address=192.168.0.0/255.255.255.0


#设置ADSL拔号
/ interface pppoe-client add name="pppoe-out1" interface=ether2 user="wwwszwblmcom@163.gd" password="88888888" add-default-route=no disabled=no
/ interface pppoe-client enable pppoe-out1

/ interface pppoe-client add name="pppoe-out2" interface=ether3 user="wwwszwblmcom@163.gd" password="88888888" add-default-route=no disabled=no
/ interface pppoe-client enable pppoe-out2

/ interface pppoe-client add name="pppoe-out2" interface=ether4 user="wwwszwblmcom@163.gd" password="88888888" add-default-route=no disabled=no
/ interface pppoe-client enable pppoe-out3


#设置ADSL虚拟IP
/ ip address add address=58.58.58.51/32 interface=pppoe-out1 comment="adsl1"
/ ip address add address=58.58.58.52/32 interface=pppoe-out2 comment="adsl2"
/ ip address add address=58.58.58.53/32 interface=pppoe-out3 comment="adsl3"

#设置分流上网
/ ip firewall mangle add chain=prerouting src-address=192.168.0.1-192.168.0.20 action=mark-routing new-routing-mark=adsl1 comment=adsl1
/ ip firewall mangle add chain=prerouting src-address=192.168.0.21-192.168.0.30 action=mark-routing new-routing-mark=adsl2 comment=adsl2
/ ip firewall mangle add chain=prerouting src-address=192.168.0.31-192.168.0.40 action=mark-routing new-routing-mark=adsl3 comment=adsl3


#设置路由表
/ ip route add gateway=58.58.58.51 routing-mark=adsl1 comment=adsl1
/ ip route add gateway=58.58.58.52 routing-mark=adsl2 comment=adsl2
/ ip route add gateway=58.58.58.53 routing-mark=adsl3 comment=adsl3

 

#设置脚本
:local assign-address
:local new-address
:local status
:local x
:set x 3
:for i from=1 to=$x do={
:set status [/interface get [/interface find  name=("pppoe-out" . $i)] running] 
:if ($status=true) do={
:set new-address [/ip address get [/ip address find dynamic=yes interface=("pppoe-out" . $i)] address]
:set new-address [:pick $new-address 0 [:find $new-address "/"]]
:set assign-address [/ip address get [/ip address find dynamic=no interface=("pppoe-out" . $i)] address]
:set assign-address [:pick $assign-address 0 [:find $assign-address "/"]]
:if ($assign-address != $new-address) do={
/ip address set [/ip address find comment=("adsl" . $i)] address=$new-address network=$new-address broadcast=$new-address
/ip route set [/ip route find comment=("adsl" . $i)] gateway=$new-address
}
}
}

本文使用Blog_Backup未注册版本导出,请到soft.pt42.com注册。

转载于:https://www.cnblogs.com/lvcisco/p/4041935.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值