
vou vincular 3 linhas de internet em uma única rede.
estou usando roteador Mikrotik RB750, configurei esse roteador assim:
/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
Nota: O roteador possui 5 portas físicas (WAN1,WAN2,WAN3,WAN4,WAN5) e 1 porta sem fio. Porta WAN1 e Wireless conectadas juntas Bridge1
e todos os nós da rede conectados à Bridge1 (WAN1 ou Wireless), agora não há problema na ligação à Internet e está funcionando bem. mas quando um nó desta rede deseja visitar um site (por exemplo: google.com), a solicitação será enviada para google.com de todas as linhas da internet! então para cada nó estamos enviando mais 2 solicitações para um único site!
Quero dividir essas linhas de internet entre os nós da rede, por exemplo cada faixa de IP usa uma linha de internet específica, assim:
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
É possível? pode me ajudar?
Responder1
Você está tentando usar o PCC (classificador por conexão), mas o que você pede é o balanceamento de carga com base no intervalo de endereços IP de origem.
Remova as seguintes regras da sua configuração:
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
E adicione o seguinte:
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
Não há necessidade de marcar as conexões e depois marcar a rota. Você pode marcar a rota diretamente com base no intervalo de endereços de origem.