天天看點

routeros雙ADSL負載平衡腳本

# may/25/2013 09:26:48 by RouterOS 5.20

/ip firewall mangle
add action=mark-connection chain=input disabled=no in-interface=pppoe-out1 new-connection-mark=wan1_conn passthrough=yes
add action=mark-connection chain=input disabled=no in-interface=pppoe-out2 new-connection-mark=wan2_conn passthrough=yes
add action=mark-routing chain=output connection-mark=wan1_conn disabled=no new-routing-mark=to_wan1 passthrough=yes
add action=mark-routing chain=output connection-mark=wan2_conn disabled=no new-routing-mark=to_wan2 passthrough=yes
add action=mark-connection chain=prerouting disabled=no dst-address-type=!local in-interface=wan1 new-connection-mark=wan1_conn passthrough=yes \
    per-connection-classifier=both-addresses-and-ports:2/0
add action=mark-connection chain=prerouting disabled=no dst-address-type=!local in-interface=wan1 new-connection-mark=wan2_conn passthrough=yes \
    per-connection-classifier=both-addresses-and-ports:2/1
add action=mark-connection chain=prerouting disabled=no dst-address-type=!local in-interface=wan2 new-connection-mark=wan1_conn passthrough=yes \
    per-connection-classifier=both-addresses-and-ports:2/0
add action=mark-connection chain=prerouting disabled=no dst-address-type=!local in-interface=wan2 new-connection-mark=wan2_conn passthrough=yes \
    per-connection-classifier=both-addresses-and-ports:2/1
add action=mark-routing chain=prerouting connection-mark=wan1_conn disabled=no in-interface=wan1 new-routing-mark=to_wan1 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=wan2_conn disabled=no in-interface=wan1 new-routing-mark=to_wan2 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=wan1_conn disabled=no in-interface=wan2 new-routing-mark=to_wan1 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=wan2_conn disabled=no in-interface=wan2 new-routing-mark=to_wan2 passthrough=yes
	
/ip firewall nat
add action=masquerade chain=srcnat disabled=no out-interface=pppoe-out1
add action=masquerade chain=srcnat disabled=no out-interface=pppoe-out2

/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=pppoe-out1 routing-mark=to_wan1 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_wan2 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
           

這個腳本是從老外Alex複制來的。

親證好用,他原來是4線的。

可以往上加,修改2/0 2/1 為4/0 4/1 4/2 4/3網銀也好用,并且下載下傳帶寬可以疊加。

interfaces裡,撥号端是 wan1 wan2; 

接區域網路是 lanPPPOE撥号是 pppoe-out1和pppoe-out2,使用這個預設名字比較好。

這幾個符号改來改去,比較容易混淆。

網卡界面和撥号需要手動添加一下,主要是mangle和route兩部分。

複制後,在new terminal裡面粘貼就可以了。

繼續閱讀