Hi guys,
I have 2 WAN connections, namely ISP1 (1.1.1.1) and ISP2 (2.2.2.1), each on a different MT interface (ISP1 respectively ISP2). On the LAN side I have a few private subnets, 10.0.1.0/24 (interface LAN1) and 10.0.2.0/24 (LAN2). I also have dst-nat for both public IPs into the LANs.
My goal is to use the ISP1 as the default outgoing interface and use ISP2 only as backup. In the same time if flows come on either ISP1 or ISP2 interfaces I want to use the same interface for outgoing packets.
I’ve figured out these steps (please correct me if I’m wrong):
-
- mark the incoming connections in order to be able to track on which interface they arrived and use the routing mark to select different lookup tables
- mark the incoming connections in order to be able to track on which interface they arrived and use the routing mark to select different lookup tables
-
- mark the outgoing connections (originating from LAN) with the routing mark for default table that I want to use (in order to exit the default ISP1 interface)
- mark the outgoing connections (originating from LAN) with the routing mark for default table that I want to use (in order to exit the default ISP1 interface)
-
- add 2 route rules, one for each routing-mark to lookup in the desired tables
- add 2 route rules, one for each routing-mark to lookup in the desired tables
-
- populate the routing tables corresponding to each routing mark
- populate the routing tables corresponding to each routing mark
-
- add the src and dst nat rules
Now I’ve done all this except it’s not working, that is I cannot exit to the internet. So obviously there’s something I didn’t do or did wrong. I suspect the mangle rules are the reason. Below is my actual configuration:
/ip address
add address=1.1.1.1/30 comment=“ISP1, default” disabled=no interface=ISP1 network=1.1.1.0
add address=2.2.2.1/30 comment=“ISP2, backup” disabled=no interface=ISP2 network=2.2.2.0
add address=10.0.1.1/24 comment=“LAN1” disabled=no interface=LAN1 network=10.0.1.0
add address=10.0.2.1/24 comment=“LAN2” disabled=no interface=LAN2 network=10.0.2.0
/ip firewall mangle
add action=mark-connection chain=prerouting disabled=no in-interface=ISP1 new-connection-mark=ISP1 passthrough=no
add action=mark-connection chain=prerouting disabled=no in-interface=ISP2 new-connection-mark=ISP2 passthrough=no
add action=mark-routing chain=prerouting comment=“LAN packets marked with ‘ISP2’ are stamped with routing mark ‘to_ISP2’”
connection-mark=ISP2 disabled=no src-address-list=lans new-routing-mark=to_ISP2 passthrough=no
add action=mark-routing chain=prerouting comment=“LAN packets marked with ‘ISP1’ are stamped with routing mark ‘to_ISP1’”
connection-mark=ISP1 disabled=no src-address-list=lans new-routing-mark=to_ISP1 passthrough=no
add action=mark-routing chain=prerouting comment=“LAN packets not previously marked are by default stamped with routing mark ‘to_ISP1’”
disabled=no new-routing-mark=to_ISP1 passthrough=no src-address-list=lans
/ip firewall nat
add action=masquerade chain=srcnat disabled=no dst-address-list=!lans src-address-list=lans
/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=2.2.2.2 routing-mark=to_ISP2 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=10 dst-address=0.0.0.0/0 gateway=1.1.1.2 routing-mark=to_ISP2 scope=30 target-scope=10
add disabled=no distance=1 dst-address=10.0.1.0/24 gateway=LAN1 routing-mark=to_ISP2 scope=30 target-scope=10
add disabled=no distance=1 dst-address=10.0.2.0/24 gateway=LAN2 routing-mark=to_ISP2 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=1.1.1.2 routing-mark=to_ISP1 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=10 dst-address=0.0.0.0/0 gateway=2.2.2.2 routing-mark=to_ISP1 scope=30 target-scope=10
add disabled=no distance=1 dst-address=10.0.1.0/24 gateway=LAN1 routing-mark=to_ISP1 scope=30 target-scope=10
add disabled=no distance=1 dst-address=10.0.2.0/24 gateway=LAN2 routing-mark=to_ISP1 scope=30 target-scope=10
/ip route rule
add action=lookup disabled=no routing-mark=to_ISP1 table=to_ISP1
add action=lookup disabled=no routing-mark=to_ISP2 table=to_ISP2
/ip firewall address-list
add list=lans address=10.0.1.0/24
add list=lans address=10.0.2.0/24Help is greatly appreciated, thanks!