A possiblity, I have done something very similar to this, but have not
tested this one. Likely needing scripting to setup next hop address for new
WAN routes if using DHCP for WAN interfaces.
Note: This assumes something near a default firewall configuration.
Define some IP Address ranges and ports.
The wireguard ports , and names.
wg1@link1 from WAN1 <-> WAN1 port = 13131 at both ends
wg2@link2 from WAN2 <-> WAN2 port = 13231 at both ends
Note: This 2 links will be force locked to the correct WAN interfaces.
** This does mean if WAN1 on Site A goes down, and WAN2 on Site B goes down,
** there will be no connectivity unless manually allowed.
IP Address ranges:
Wireguard interfaces.
192.168.100.0/30 for wg1@link1 (Site A has 192.168.100.1/30, Site B has 192.168.100.2/30)
192.168.100.8/30 for wg2@link2 (Site A has 192.168.100.9/30, Site B has 192.168.100.10/30)
Site IP Address ranges
Site A has 192.168.0.0/22
Site B has 192.168.8.0/22
Configuration...
If not already done create the 2 wireguard interfaces on each router.
wg1 for @link1
wg2 for @link2
Add these interfaces to the LAN interface list on their router.
And add IP addresses.
(will add peers later)
Site A
/interface list member
add interface=wg1 list=LAN
add interface=wg2 list=LAN
/ip address add 192.168.100.1/30 interface=wg1
/ip address add 192.168.100.9/30 interface=wg2
/ip route add blackhole disabled=no dst-address=192.168.100.0/24 gateway="" \
distance=100 routing-table=main
Site B
/interface list member
add interface=wg1 list=LAN
add interface=wg2 list=LAN
/ip address add 192.168.100.2/30 interface=wg1
/ip address add 192.168.100.10/30 interface=wg2
/ip route add blackhole disabled=no dst-address=192.168.100.0/24 gateway="" \
distance=100 routing-table=main
Add 2 routes on both routers.
Site A
/ip route
add check-gateway=ping comment="@link1 to 3.3.3.3 prefers to use WAN1" \
distance=5 dst-address=3.3.3.3 gateway=WAN1 routing-table=main
add check-gateway=ping comment="@link2 to 4.4.4.4 prefers to use WAN2" \
distance=5 dst-address=4.4.4.4 gateway=WAN2 routing-table=main
Site B
/ip route
add check-gateway=ping comment="@link1 to 1.1.1.1 prefers to use WAN1" \
distance=5 dst-address=1.1.1.1 gateway=WAN1 routing-table=main
add check-gateway=ping comment="@link2 to 2.2.2.2 prefers to use WAN2" \
distance=5 dst-address=2.2.2.2 gateway=WAN2 routing-table=main
Add some firewall rules, so cannot send wg1@link1 via WAN2, or wg2@link2 via WAN1
Also rules to drop wg@link1 coming in WAN2 and wg@link2 coming in WAN1
Site A
/ip firewall raw
add action=drop chain=output dst-address=3.3.3.3 out-interface=WAN2 dst-port=13131 \
protocol=udp disabled=yes
add action=drop chain=output dst-address=4.4.4.4 out-interface=WAN1 dst-port=13231 \
protocol=udp disabled=yes
add action=drop chain=prerouting src-address=3.3.3.3 in-interface=WAN2 dst-port=13131 \
protocol=udp
add action=drop chain=output src-address=4.4.4.4 in-interface=WAN1 dst-port=13231 \
protocol=udp
Site B
/ip firewall raw
add action=drop chain=output dst-address=1.1.1.1 out-interface=WAN2 dst-port=13131 \
protocol=udp disabled=yes
add action=drop chain=output dst-address=2.2.2.2 out-interface=WAN1 dst-port=13231 \
protocol=udp disabled=yes
add action=drop chain=prerouting src-address=1.1.1.1 in-interface=WAN2 dst-port=13131 \
protocol=udp
add action=drop chain=output src-address=2.2.2.2 in-interface=WAN1 dst-port=13231 \
protocol=udp
Add rules to allow the wireguard traffic
(Note: Could restrict input to a specific interface rather than in raw rules above)
Site A
/ip firewall filter
add action=accept chain=input dst-port=13131 protocol=udp
add action=accept chain=input dst-port=13231 protocol=udp
Site B
/ip firewall filter
add action=accept chain=input dst-port=13131 protocol=udp
add action=accept chain=input dst-port=13231 protocol=udp
Create the wireguard peers with appropriate allowed addresses.
(Using public key from remote wg peer)
Site A
/ip wireguard peers
add allowed-address=192.168.100.2,192.168.8.0/22 interface=wg1 name=wg1link1 \
endpoint-address=3.3.3.3 endpoint-port=13131 public-key=SITEB-wg1-PUBLICKEY
add allowed-address=192.168.100.10,192.168.8.0/22 interface=wg2 name=wg2link2 \
endpoint-address=4.4.4.4 endpoint-port=13231 public-key=SITEB-wg2-PUBLICKEY
Site B
/ip wireguard peers
add allowed-address=192.168.100.1,192.168.0.0/22 interface=wg1 name=wg1link1 \
endpoint-address=1.1.1.1 endpoint-port=13131 public-key=SITEA-wg1-PUBLICKEY
add allowed-address=192.168.100.9,192.168.0.0/22 interface=wg2 name=wg2link2 \
endpoint-address=2.2.2.2 endpoint-port=13231 public-key=SITEA-wg2-PUBLICKEY
Next add Routes to the other sites IP addresses. (Static in this case,
you could use ospf or similar)
Will use a recursive lookup via the wg interface addresses with ping.
(So if a wg connection is not working, routing will use the remaining link)
Site A
# wg1
/ip route add check-gateway=ping dst-address=192.168.8.0/22 gateway=192.168.100.2 routing-table=main
#wg2
/ip route add check-gateway=ping dst-address=192.168.8.0/22 gateway=192.168.100.10 routing-table=main
#disallow via another route.
/ip route add blackhole distance=100 dst-address=192.168.8.0/22 gateway="" routing-table=main
Site B
# wg1
/ip route add check-gateway=ping dst-address=192.168.0.0/22 gateway=192.168.100.1 routing-table=main
#wg2
/ip route add check-gateway=ping dst-address=192.168.0.0/22 gateway=192.168.100.9 routing-table=main
#disallow via another route.
/ip route add blackhole distance=100 dst-address=192.168.0.0/22 gateway="" routing-table=main
This with luck should give you 2 connected wg links, with ecmp.
You can then put pcc routing on top of this.