找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 22537|回复: 31

[负载平衡] RouterOS v3.24版本PCC多线负载均衡设置教程

  [复制链接]
发表于 2009-7-1 20:11:05 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
本帖最后由 3148715 于 2009-7-1 20:15 编辑

三线例子代码

/ip firewall mangle add chain=prerouting action=mark-connection new-connection-mark=1st_conn per-connection-classifier=src-address-and-port:3/0
/ip firewall mangle add chain=prerouting action=mark-connection new-connection-mark=2nd_conn per-connection-classifier=src-address-and-port:3/1
/ip firewall mangle add chain=prerouting action=mark-connection new-connection-mark=3rd_conn per-connection-classifier=src-address-and-port:3/2


以下是二线设置代码
说明:Local为内网 wlan1、wlan2为外网
1.jpg






/ ip address
add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=Local
add address=10.111.0.2/24 network=10.111.0.0 broadcast=10.111.0.255 interface=wlan2
add address=10.112.0.2/24 network=10.112.0.0 broadcast=10.112.0.255 interface=wlan1

/ ip firewall mangle
add chain=input in-interface=wlan1 action=mark-connection new-connection-mark=wlan1_conn
add chain=input in-interface=wlan2 action=mark-connection new-connection-mark=wlan2_conn
add chain=output connection-mark=wlan1_conn action=mark-routing new-routing-mark=to_wlan1
add chain=output connection-mark=wlan2_conn action=mark-routing new-routing-mark=to_wlan2
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses:2/0 \
action=mark-connection new-connection-mark=wlan1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses:2/1 \
action=mark-connection new-connection-mark=wlan2_conn passthrough=yes
add chain=prerouting connection-mark=wlan1_conn in-interface=Local action=mark-routing new-routing-mark=to_wlan1
add chain=prerouting connection-mark=wlan2_conn in-interface=Local action=mark-routing new-routing-mark=to_wlan2

/ ip route
add dst-address=0.0.0.0/0 gateway=10.111.0.1 routing-mark=to_wlan1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=10.112.0.1 routing-mark=to_wlan2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=10.111.0.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=10.112.0.1 distance=2 check-gateway=ping

/ ip firewall nat
add chain=srcnat out-interface=wlan1 action=masquerade
add chain=srcnat out-interface=wlan2 action=masquerade



如果你是ADSL动态IP和动态网关,请用动态脚本改变
:global assignaddress
:global newaddress
:global status
:global x
:global i
:set x 2
:for i from=1 to=$x do={
:set status [/interface get [/interface find name=("pppoe-out" . $i)] running]
:if ($status=true) do={
:set newaddress [/ip address get [/ip address find dynamic=yes interface=("pppoe-out" . $i)] address]
:set newaddress [:pick $newaddress 0 [:find $newaddress "/">
:set assignaddress [/ip address get [/ip address find dynamic=no interface=("pppoe-out" . $i)] address]
:set assignaddress [:pick $assignaddress 0 [:find $assignaddress "/">
:if ($assignaddress != $newaddress) do={
/ip address set [/ip address find comment=("adsl" . $i)] address=$newaddress network=$newaddress broadcast=$newaddress
/ip route set [/ip route find comment=("adsl" . $i)] gateway=$newaddress
}
}
}
2.jpg
routeros
发表于 2009-7-1 21:34:41 | 显示全部楼层
不要重复发了
routeros
回复

使用道具 举报

发表于 2009-7-2 07:41:02 | 显示全部楼层
3.X新版本,可以更简化。
routeros
回复

使用道具 举报

发表于 2009-7-2 08:08:05 | 显示全部楼层
可恶,转的也不注明出处
routeros
回复

使用道具 举报

发表于 2009-7-2 13:12:18 | 显示全部楼层
这些设置都淘汰了
routeros
回复

使用道具 举报

发表于 2009-7-2 17:28:34 | 显示全部楼层
5# WGHBOY

淘汰了,这PCC负载均衡版本才刚出来
routeros
回复

使用道具 举报

 楼主| 发表于 2009-7-2 17:36:37 | 显示全部楼层
别人是大师级人物,他和我们不是一个等级的人。。知道不

routeros
回复

使用道具 举报

发表于 2009-7-2 18:00:35 | 显示全部楼层
routeros
回复

使用道具 举报

发表于 2009-7-3 01:21:09 | 显示全部楼层
不管如何,先保存了再说
routeros
回复

使用道具 举报

发表于 2009-7-13 19:28:53 | 显示全部楼层
咳咳 咳咳
routeros
回复

使用道具 举报

发表于 2009-9-22 11:52:54 | 显示全部楼层
啊?有从2.297过来的?
routeros
回复

使用道具 举报

发表于 2010-3-7 21:06:00 | 显示全部楼层
/ ip route
add dst-address=0.0.0.0/0 gateway=10.111.0.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=10.112.0.1 distance=2 check-gateway=ping


这两条到底有什么用啊?放进去之后不在“有效”状态的?
删除了,照样可以负载啊。
routeros
回复

使用道具 举报

发表于 2010-3-8 15:06:37 | 显示全部楼层
kkkkkkkk
routeros
回复

使用道具 举报

发表于 2010-3-9 16:01:05 | 显示全部楼层
本帖最后由 billzhong 于 2010-3-9 16:02 编辑

双线PCC,不需要什么更新网关的脚本,PCC不好玩:


/ip route
add check-gateway=ping comment="" disabled=no distance=1 dst-address=\
    0.0.0.0/0 gateway=pppoe-out1 routing-mark=to_P1 scope=30 target-scope=10
add check-gateway=ping comment="" disabled=no distance=1 dst-address=\
    0.0.0.0/0 gateway=pppoe-out2 routing-mark=to_P2 scope=30 target-scope=10

/ip firewall nat
add action=masquerade chain=srcnat comment="" disabled=no out-interface=\
    pppoe-out1
add action=masquerade chain=srcnat comment="" disabled=no out-interface=\
    pppoe-out2
add action=masquerade chain=srcnat comment="" disabled=no

/ip firewall mangle
add action=mark-connection chain=input comment="" disabled=no in-interface=\
    pppoe-out1 new-connection-mark=P1 passthrough=yes
add action=mark-connection chain=input comment="" disabled=no in-interface=\
    pppoe-out2 new-connection-mark=P2 passthrough=yes
add action=mark-routing chain=output comment="" connection-mark=P1 disabled=\
    no new-routing-mark=to_P1 passthrough=yes
add action=mark-routing chain=output comment="" connection-mark=P2 disabled=\
    no new-routing-mark=to_P2 passthrough=yes
add action=mark-connection chain=prerouting comment="" disabled=no \
    dst-address-type=!local in-interface=LAN new-connection-mark=P1 \
    passthrough=yes per-connection-classifier=both-addresses:2/0
add action=mark-connection chain=prerouting comment="" disabled=no \
    dst-address-type=!local in-interface=LAN new-connection-mark=P2 \
    passthrough=yes per-connection-classifier=both-addresses:2/1
add action=mark-routing chain=prerouting comment="" connection-mark=P1 \
    disabled=no in-interface=LAN new-routing-mark=to_P1 passthrough=yes
add action=mark-routing chain=prerouting comment="" connection-mark=P2 \
    disabled=no in-interface=LAN new-routing-mark=to_P2 passthrough=yes
add action=change-mss chain=forward comment="" disabled=no new-mss=1300 \
    protocol=tcp tcp-flags=syn
add action=accept chain=prerouting comment="" disabled=no
routeros
回复

使用道具 举报

发表于 2010-3-19 10:51:06 | 显示全部楼层
2.9又玩不了
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-11-24 19:46 , Processed in 0.095723 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表