RouterOS/MultiWAN

De GeRgOsNet

Configuration d'un MultiWAN (plusieurs connection, ici 4) :

Ce mettre sur le port 8 !

/interface
set ether1-gateway name=Local
set ether2 name=WAN1
set ether3 name=WAN2
set ether4 name=WAN3
set ether5 name=WAN4


/ip address
add address=192.168.3.252/24 network=192.168.3.0 broadcast=192.168.3.255 interface=Local
add address=192.168.4.252/24 network=192.168.4.0 broadcast=192.168.4.255 interface=WAN1
add address=192.168.6.252/24 network=192.168.6.0 broadcast=192.168.6.255 interface=WAN2
add address=192.168.7.252/24 network=192.168.7.0 broadcast=192.168.7.255 interface=WAN3
add address=192.168.8.252/24 network=192.168.8.0 broadcast=192.168.8.255 interface=WAN4
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
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=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
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=prerouting dst-address=192.168.4.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.6.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.7.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.8.0/24 action=accept in-interface=Local

add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/0 action=mark-connection new-connection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/1 action=mark-connection new-connection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/2 action=mark-connection new-connection-mark=WAN3_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:4/3 action=mark-connection new-connection-mark=WAN4_conn passthrough=yes

add chain=prerouting connection-mark=WAN1_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN1
add chain=prerouting connection-mark=WAN2_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN2
add chain=prerouting connection-mark=WAN3_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN3
add chain=prerouting connection-mark=WAN4_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN4
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.4.250 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.6.240 routing-mark=to_WAN2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.7.240 routing-mark=to_WAN3 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.8.240 routing-mark=to_WAN4 check-gateway=ping

add dst-address=0.0.0.0/0 gateway=192.168.4.250 distance=2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.6.240 distance=2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.7.240 distance=2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.8.240 distance=2 check-gateway=ping
/ip firewall nat
add chain=srcnat out-interface=WAN1 action=masquerade
add chain=srcnat out-interface=WAN2 action=masquerade
add chain=srcnat out-interface=WAN3 action=masquerade
add chain=srcnat out-interface=WAN4 action=masquerade
/ip firewall filter
add chain=input action=accept protocol=icmp log=no log-prefix="" 
add chain=input action=accept connection-state=established log=no log-prefix="" 
add chain=input action=accept connection-state=related log=no log-prefix="" 
add chain=input action=accept in-interface=Local log=no log-prefix="" 
add chain=forward action=accept connection-state=established log=no log-prefix="" 
add chain=forward action=accept connection-state=related log=no log-prefix="" 
add chain=forward action=drop connection-state=invalid log=no log-prefix="" 


/interface brigde
port disable numbers=0
port disable numbers=1
port disable numbers=2
port disable numbers=3
port disable numbers=4