我要将 3 条互联网线路绑定在一个网络中。
我正在使用 Mikrotik RB750 路由器,我按如下方式配置该路由器:
/ip firewall mangle
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
add chain=input in-interface=WAN3 action=mark-connection new-connection-mark=WAN3_conn
add chain=input in-interface=WAN4 action=mark-connection new-connection-mark=WAN4_conn
add chain=input in-interface=WAN5 action=mark-connection new-connection-mark=WAN5_conn
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2
add chain=output connection-mark=WAN3_conn action=mark-routing new-routing-mark=to_WAN3
add chain=output connection-mark=WAN4_conn action=mark-routing new-routing-mark=to_WAN4
add chain=output connection-mark=WAN5_conn action=mark-routing new-routing-mark=to_WAN5
add chain=prerouting dst-address=192.168.2.0/24 action=accept in-interface=bridge1
add chain=prerouting dst-address=192.168.3.0/24 action=accept in-interface=bridge1
add chain=prerouting dst-address=192.168.4.0/24 action=accept in-interface=bridge1
add chain=prerouting dst-address=192.168.5.0/24 action=accept in-interface=bridge1
add chain=prerouting dst-address-type=!local in-interface=bridge1 per-connection-classifier=both-addresses-and-ports:4/0 action=mark-connection new-connection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=bridge1 per-connection-classifier=both-addresses-and-ports:4/1 action=mark-connection new-connection-mark=WAN3_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=bridge1 per-connection-classifier=both-addresses-and-ports:4/2 action=mark-connection new-connection-mark=WAN4_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=bridge1 per-connection-classifier=both-addresses-and-ports:4/3 action=mark-connection new-connection-mark=WAN5_conn passthrough=yes
add chain=prerouting connection-mark=WAN2_conn in-interface=bridge1 action=mark-routing new-routing-mark=to_WAN2
add chain=prerouting connection-mark=WAN3_conn in-interface=bridge1 action=mark-routing new-routing-mark=to_WAN3
add chain=prerouting connection-mark=WAN4_conn in-interface=bridge1 action=mark-routing new-routing-mark=to_WAN4
add chain=prerouting connection-mark=WAN5_conn in-interface=bridge1 action=mark-routing new-routing-mark=to_WAN5
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_WAN2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.3.1 routing-mark=to_WAN3 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.4.1 routing-mark=to_WAN4 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.5.1 routing-mark=to_WAN5 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.3.1 distance=2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.4.1 distance=2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.5.1 distance=2 check-gateway=ping
/ip firewall nat
add chain=srcnat out-interface=WAN2 action=masquerade
add chain=srcnat out-interface=WAN3 action=masquerade
add chain=srcnat out-interface=WAN4 action=masquerade
add chain=srcnat out-interface=WAN5 action=masquerade
注意:路由器有 5 个物理端口(WAN1、WAN2、WAN3、WAN4、WAN5)和 1 个无线端口。WAN1 和无线端口通过Bridge1
Bridge1(WAN1 或无线)连接在一起,网络中的所有节点都连接到 Bridge1,现在互联网绑定没有问题,并且运行良好。但是当此网络中的节点想要访问网站(例如:google.com)时,请求将从所有互联网线路发送到 google.com!因此,对于每个节点,我们都会向单个网站发送 2 个以上的请求!
我想在网络节点之间划分这些互联网线路,例如每个 IP 范围使用特定的互联网线路,如下所示:
192.168.1.1 - 192.168.1.64: Use first Internet line
192.168.1.65 - 192.168.1.128: Use second Internet line
192.168.1.129 - 192.168.1.254: Use third Internet line
有可能吗?你能帮助我吗?
答案1
您正在尝试使用 PCC(每个连接分类器),但您要求的是基于源 IP 地址范围的负载平衡。
从您的配置中删除以下规则:
add chain=prerouting dst-address-type=!local in-interface=bridge1 per-connection-classifier=both-addresses-and-ports:4/0 action=mark-connection new-connection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=bridge1 per-connection-classifier=both-addresses-and-ports:4/1 action=mark-connection new-connection-mark=WAN3_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=bridge1 per-connection-classifier=both-addresses-and-ports:4/2 action=mark-connection new-connection-mark=WAN4_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=bridge1 per-connection-classifier=both-addresses-and-ports:4/3 action=mark-connection new-connection-mark=WAN5_conn passthrough=yes
add chain=prerouting connection-mark=WAN2_conn in-interface=bridge1 action=mark-routing new-routing-mark=to_WAN2
add chain=prerouting connection-mark=WAN3_conn in-interface=bridge1 action=mark-routing new-routing-mark=to_WAN3
add chain=prerouting connection-mark=WAN4_conn in-interface=bridge1 action=mark-routing new-routing-mark=to_WAN4
add chain=prerouting connection-mark=WAN5_conn in-interface=bridge1 action=mark-routing new-routing-mark=to_WAN5
并添加以下内容:
add chain=prerouting src-address=192.168.1.0/26 in-interface=bridge1 dst-address=!192.168.1.0/24 action=mark-routing disabled=no new-routing-mark=to_WAN2 passthrough=no
add chain=prerouting src-address=192.168.1.64/26 in-interface=bridge1 dst-address=!192.168.1.0/24 action=mark-routing disabled=no new-routing-mark=to_WAN3 passthrough=no
add chain=prerouting src-address=192.168.1.128/25 in-interface=bridge1 dst-address=!192.168.1.0/24 action=mark-routing disabled=no new-routing-mark=to_WAN4 passthrough=no
不需要先标记连接再进行路由标记,直接根据源地址范围进行路由标记即可。