本次列出使用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