You can add routing rules based on destination port -- if the (remote) endpoint port of the first WireGuard tunnel was 51821
, and the second was 51822
, you could add the following routing rules to use routing table 1 for the first, and routing table 2 for the second:
ip rule add dport 58121 table 1 priority 101
ip rule add dport 58122 table 2 priority 102
Then if your WAN interfaces are eth1
and eth2
(and WAN gateway is for example 203.0.113.1
), you could set the default route of table 1 to use the first interface, and table 2 to use the second interface:
ip route add default via 203.0.113.1 dev eth1 table 1
ip route add default via 203.0.113.1 dev eth2 table 2
Alternatively, you could add routing rules based on firewall mark, which you may (or may not) find more maintainable than using destination port. If you configured one (local) WireGuard interface with say FwMark = 11
and the second with FwMark = 22
, you could use these routing rules instead:
ip rule add fwmark 11 table 1 priority 101
ip rule add fwmark 22 table 2 priority 102