linux单网卡多拨Adsl,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
}
}
}
總結
以上是生活随笔為你收集整理的linux单网卡多拨Adsl,ROS单线多拨pppoe的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux windows 丢失,Win
- 下一篇: linux生成文件清单,Linux 获取