ROS多線路負載均衡

本次列出使用PCC負載均衡實例

網上看到過教程,感覺腳本來的快點,下面就是PCC4個ADSL的負載均衡的腳本:

/ip firewall address-list
add address=192.168.88.0/24 disabled=no list=local
/ip firewall mangle
add action=mark-connection chain=input disabled=no in-interface=pppoe-out1 \
new-connection-mark=pppoe-out1 passthrough=yes
add action=mark-connection chain=input disabled=no in-interface=pppoe-out2 \
new-connection-mark=pppoe-out2 passthrough=yes
add action=mark-connection chain=input disabled=no in-interface=pppoe-out3 \
new-connection-mark=pppoe-out3 passthrough=yes
add action=mark-connection chain=input disabled=no in-interface=pppoe-out4 \
new-connection-mark=pppoe-out4 passthrough=yes
add action=mark-routing chain=output connection-mark=pppoe-out1 disabled=no \
new-routing-mark=to_pppoe-out1 passthrough=yes
add action=mark-routing chain=output connection-mark=pppoe-out2 disabled=no \
new-routing-mark=to_pppoe-out2 passthrough=yes
add action=mark-routing chain=output connection-mark=pppoe-out3 disabled=no \
new-routing-mark=to_pppoe-out3 passthrough=yes
add action=mark-routing chain=output connection-mark=pppoe-out4 disabled=no \
new-routing-mark=to_pppoe-out4 passthrough=yes
add action=mark-connection chain=prerouting disabled=no dst-address-list=\
!local dst-address-type=!local new-connection-mark=pppoe-out1 \
passthrough=yes per-connection-classifier=both-addresses:4/0 \
src-address-list=local
add action=mark-connection chain=prerouting disabled=no dst-address-list=\
!local dst-address-type=!local new-connection-mark=pppoe-out2 \
passthrough=yes per-connection-classifier=both-addresses:4/1 \
src-address-list=local
add action=mark-connection chain=prerouting disabled=no dst-address-list=\
!local dst-address-type=!local new-connection-mark=pppoe-out3 \
passthrough=yes per-connection-classifier=both-addresses:4/2\
src-address-list=local
add action=mark-connection chain=prerouting disabled=no dst-address-list=\
!local dst-address-type=!local new-connection-mark=pppoe-out4 \
passthrough=yes per-connection-classifier=both-addresses:4/3 \
src-address-list=local
add action=mark-routing chain=prerouting connection-mark=pppoe-out1 disabled=\
no new-routing-mark=to_pppoe-out1 passthrough=no src-address-list=local
add action=mark-routing chain=prerouting connection-mark=pppoe-out2 disabled=\
no new-routing-mark=to_pppoe-out2 passthrough=no src-address-list=local
add action=mark-routing chain=prerouting connection-mark=pppoe-out3 disabled=\
no new-routing-mark=to_pppoe-out3 passthrough=no src-address-list=local
add action=mark-routing chain=prerouting connection-mark=pppoe-out4 disabled=\
no new-routing-mark=to_pppoe-out4 passthrough=no src-address-list=local

/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
pppoe-out1 routing-mark=to_pppoe-out1 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
pppoe-out2 routing-mark=to_pppoe-out2 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
pppoe-out3 routing-mark=to_pppoe-out3 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
pppoe-out4 routing-mark=to_pppoe-out4 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
pppoe-out1 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=2 dst-address=0.0.0.0/0 gateway=\
pppoe-out2 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
pppoe-out3 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=2 dst-address=0.0.0.0/0 gateway=\
pppoe-out4 scope=30 target-scope=10


進入winbox ->NewTerminal ,在控制檯paste以上腳本即可。

如果是固定4個IP的,可以將pppoe-out(1-4)改成ethernet(1-4),如果只有2個ADSL(或固定IP),代碼中的
add action=mark-connection chain=prerouting disabled=no dst-address-list=\
   !local dst-address-type=!local new-connection-mark=pppoe-out1 \
   passthrough=yes per-connection-classifier=both-addresses:4/0 \
   src-address-list=local
add action=mark-connection chain=prerouting disabled=no dst-address-list=\
   !local dst-address-type=!local new-connection-mark=pppoe-out2 \
   passthrough=yes per-connection-classifier=both-addresses:4/1 \
   src-address-list=local
add action=mark-connection chain=prerouting disabled=no dst-address-list=\
   !local dst-address-type=!local new-connection-mark=pppoe-out3 \
   passthrough=yes per-connection-classifier=both-addresses:4/2\
   src-address-list=local
add action=mark-connection chain=prerouting disabled=no dst-address-list=\
   !local dst-address-type=!local new-connection-mark=pppoe-out4 \
   passthrough=yes per-connection-classifier=both-addresses:4/3 \
   src-address-list=local

要改成
add action=mark-connection chain=prerouting disabled=no dst-address-list=\
   !local dst-address-type=!local new-connection-mark=pppoe-out1 \
   passthrough=yes per-connection-classifier=both-addresses:2/0 \
   src-address-list=local
add action=mark-connection chain=prerouting disabled=no dst-address-list=\
   !local dst-address-type=!local new-connection-mark=pppoe-out2 \
   passthrough=yes per-connection-classifier=both-addresses:2/1 \
   src-address-list=local 。


出自 華翔博客 : http://www.looksky.net/?p=157

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章