multi-WAN, one dst always through one WAN
Posted: Sun Mar 16, 2025 11:13 pm
I read and tried to modify and implement this solution, which is about source address.
But it isn't working, and I am not sure if it is because a different solution is needed when the restriction is to destination address instead.
I have two WAN connections, which is working well. Only one of the WAN connections has a static IP from the ISP. In order to connect to the destination, I have to be listed in the firewall in front of the destination, so I want to always use the static IP WAN when I send traffic to that destination.
The traffic does not seem to be going out the static IP WAN, because it is not hitting the firewall in front of the destination.
Thank you for any suggestion.
Here are what I think are relevant lines in config:
But it isn't working, and I am not sure if it is because a different solution is needed when the restriction is to destination address instead.
I have two WAN connections, which is working well. Only one of the WAN connections has a static IP from the ISP. In order to connect to the destination, I have to be listed in the firewall in front of the destination, so I want to always use the static IP WAN when I send traffic to that destination.
The traffic does not seem to be going out the static IP WAN, because it is not hitting the firewall in front of the destination.
Thank you for any suggestion.
Here are what I think are relevant lines in config:
Code: Select all
#RouterOS 7.19beta5
/interface list member
add comment="all LAN ports bridged" disabled=no interface=bridge list=LAN
add comment="dual WAN configuration" disabled=no interface=WAN_ether1 list=\
WAN
add disabled=no interface=WAN_ether2 list=WAN
/routing table
add disabled=no fib name=to_WAN1
add disabled=no fib name=to_WAN2
add comment="For traffic that is only going out on static IP." \
disabled=no fib name=useWAN1only
/ip firewall mangle
add action=accept chain=prerouting comment=\
"https://www.youtube.com/watch\?v=GeuuNE3EPBA" dst-address=192.168.1.0/24 \
in-interface=bridge
add action=accept chain=prerouting comment=\
"https://www.youtube.com/watch\?v=GeuuNE3EPBA" dst-address=192.168.2.0/24 \
in-interface=bridge
add action=mark-connection chain=prerouting comment=\
"https://www.youtube.com/watch\?v=GeuuNE3EPBA" connection-mark=no-mark \
in-interface=WAN_ether1 new-connection-mark=WAN1_conn passthrough=yes
add action=mark-connection chain=prerouting comment=\
"https://www.youtube.com/watch\?v=GeuuNE3EPBA" connection-mark=no-mark \
in-interface=WAN_ether2 new-connection-mark=WAN2_conn passthrough=yes
add action=mark-connection chain=prerouting comment=\
"https://www.youtube.com/watch\?v=GeuuNE3EPBA" !connection-bytes \
!connection-limit connection-mark=no-mark !connection-nat-state \
!connection-rate !connection-state !connection-type !content disabled=no \
!dscp !dst-address !dst-address-list dst-address-type=!local !dst-limit \
!dst-port !fragment !hotspot !icmp-options !in-bridge-port \
!in-bridge-port-list in-interface=bridge !in-interface-list \
!ingress-priority !ipsec-policy !ipv4-options !layer7-protocol !limit \
log=no log-prefix="" new-connection-mark=WAN1_conn !nth !out-bridge-port \
!out-bridge-port-list !out-interface !out-interface-list !packet-mark \
!packet-size passthrough=yes per-connection-classifier=both-addresses:2/0 \
!port !priority !protocol !psd !random !routing-mark !src-address \
!src-address-list !src-address-type !src-mac-address !src-port !tcp-flags \
!tcp-mss !time !tls-host !ttl
add action=mark-connection chain=prerouting comment=\
"https://www.youtube.com/watch\?v=GeuuNE3EPBA" !connection-bytes \
!connection-limit connection-mark=no-mark !connection-nat-state \
!connection-rate !connection-state !connection-type !content disabled=no \
!dscp !dst-address !dst-address-list dst-address-type=!local !dst-limit \
!dst-port !fragment !hotspot !icmp-options !in-bridge-port \
!in-bridge-port-list in-interface=bridge !in-interface-list \
!ingress-priority !ipsec-policy !ipv4-options !layer7-protocol !limit \
log=no log-prefix="" new-connection-mark=WAN2_conn !nth !out-bridge-port \
!out-bridge-port-list !out-interface !out-interface-list !packet-mark \
!packet-size passthrough=yes per-connection-classifier=both-addresses:2/1 \
!port !priority !protocol !psd !random !routing-mark !src-address \
!src-address-list !src-address-type !src-mac-address !src-port !tcp-flags \
!tcp-mss !time !tls-host !ttl
add action=mark-routing chain=prerouting comment=\
"https://www.youtube.com/watch\?v=GeuuNE3EPBA" connection-mark=WAN1_conn \
in-interface=bridge new-routing-mark=to_WAN1 passthrough=yes
add action=mark-routing chain=prerouting comment=\
"https://www.youtube.com/watch\?v=GeuuNE3EPBA" connection-mark=WAN2_conn \
in-interface=bridge new-routing-mark=to_WAN2 passthrough=yes
add action=mark-routing chain=output comment=\
"https://www.youtube.com/watch\?v=GeuuNE3EPBA" connection-mark=WAN1_conn \
new-routing-mark=to_WAN1 passthrough=yes
add action=mark-routing chain=output comment=\
"https://www.youtube.com/watch\?v=GeuuNE3EPBA" connection-mark=WAN2_conn \
new-routing-mark=to_WAN2 passthrough=yes
/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
192.168.1.1 pref-src="" routing-table=to_WAN1 scope=30 \
suppress-hw-offload=no target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
192.168.2.1 pref-src="" routing-table=to_WAN2 scope=30 \
suppress-hw-offload=no target-scope=10
add comment=\
https://help.mikrotik.com/docs/display/ROS/Per+connection+classifier \
distance=1 dst-address=0.0.0.0/0 gateway=192.168.1.1
add comment=\
https://help.mikrotik.com/docs/display/ROS/Per+connection+classifier \
disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.2.1 \
pref-src="" routing-table=main scope=30 suppress-hw-offload=no \
target-scope=10
add comment="to force traffic out static IP WAN1 https://forum.mikrotik.com/\
viewtopic.php\?t=188388#p951507" disabled=no distance=1 dst-address=\
206.81.93.160/32 gateway=WAN_ether1 routing-table=useWAN1only scope=30 \
suppress-hw-offload=no target-scope=10
/routing rule
add action=lookup-only-in-table comment="to send traffic bound for specific endpoint\
only through static IP WAN https://forum.mikrotik.com/viewtopic.php\?\
t=188388#p951507" disabled=no dst-address=198.51.100.1/32 table=\
useWAN1only