I have issues with setting up wireguard routing through another wireguard tunnel and the ISP’s default gateway. The main goal is to enable WireGuard clients (wg3) to connect to hap ac3 and route all client traffic as if the mobile client is simply within the hap ac3 network so I can access geo restricted services.
On hap ac3 (gwd), there are two WireGuard tunnels, wg0 (192.168.20.0/24) and wg1,(192.168.30.0/24) to VPN servers, with all outgoing traffic routed through one of these tunnels. Additionally, BGP is used to obtain network addresses that should be routed through the ISP’s gateway on ether1. There’s also a wg2 (192.168.10.0/24) interface connected to another hap ax3, located at your parents’ home.
When connecting to hap ac3 from a mobile client, I can see all networks: 192.168.2.0/24 (hap ac3’s local network), 192.168.1.0/24 (hap ax3 network via wg2), and both VPN server networks. However, external traffic from the mobile client does not leave hap ac3, as if the routing table is not being used. Traffic from clients directly connected to hap ac3 is successfully routed either through VPN servers or the ISP gateway.
I can add masquerade rule:
add action=masquerade chain=srcnat log=yes log-prefix="masq wg3-wg0" \
out-interface=wg0 src-address-list=wireguard-clients
In this case, all outgoing traffic is routed through the VPN, ignoring routes obtained via BGP.
It seems I’ve overcomplicated the configuration but can’t find where (probably everywhere)
Some map

routeros config
wg0, wg1 - client to external vpn servers
wg2 - client to another hap ax3
wg3 - server for mobile clients, 192.168.15.0/24 subnet, test client have 192.168.15.5 address, AllowedIPs in config is 0.0.0.0/0
ether1 - ISP WAN
# 2024-08-14 11:57:50 by RouterOS 7.15.3
# software id = 3B4V-DQ23
#
# model = RBD53iG-5HacD2HnD
# serial number = [REDACTED]
/interface wireguard
add comment=wg-2 listen-port=16948 mtu=1420 name=wg0
add comment=wg-1 listen-port=41378 mtu=1420 name=wg1
add comment=to-d1 listen-port=41388 mtu=1420 name=wg2
add comment="d32 wg incoming" listen-port=51821 mtu=1420 name=wg3
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/routing bgp template
set default as=[REDACTED] hold-time=4m keepalive-time=1m multihop=yes \
output.network=bgp-networks .no-client-to-client-reflection=yes \
router-id=[REDACTED]
/routing bgp connection
add as=[REDACTED] connect=yes disabled=no input.filter=bgp-in listen=yes \
local.address=[REDACTED] .role=ebgp multihop=yes name=\
bgp-peer0 output.filter-chain=discard remote.address=\
[REDACTED] .as=[REDACTED] .port=179 router-id=[REDACTED] \
routing-table=main templates=default
/routing filter rule
add chain=discard disabled=no rule="reject;"
add chain=bgp-in disabled=no rule="set gw ether1; accept;"
/routing table
add fib name=direct
/interface bridge port
add bridge=bridge comment=defconf interface=ether2
add bridge=bridge comment=defconf interface=ether3
add bridge=bridge comment=defconf interface=ether4
add bridge=bridge comment=defconf interface=ether5
add bridge=bridge comment=defconf interface=wifi1
add bridge=bridge comment=defconf interface=wifi2
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
add interface=wg2 list=LAN
add interface=wg3 list=LAN
add interface=wg0 list=LAN
/interface wireguard peers
add allowed-address=0.0.0.0/0 comment=vpn2 endpoint-address=\
vpn-1.[REDACTED] endpoint-port=51826 interface=wg0 name=vpn-1 \
persistent-keepalive=10s public-key=\
"[REDACTED]"
add allowed-address=0.0.0.0/0 comment=vpn2 endpoint-address=\
vpn-2.[REDACTED] endpoint-port=51826 interface=wg1 name=vpn-2 \
persistent-keepalive=10s public-key=\
"[REDACTED]"
add allowed-address=0.0.0.0/0 comment="to-d1" endpoint-address=\
vpn-d1.[REDACTED] endpoint-port=59321 interface=wg2 name=gw-d1 \
persistent-keepalive=15s preshared-key=\
"[REDACTED]" public-key=\
"[REDACTED]"
add allowed-address=192.168.15.5/32 comment=iphone endpoint-address=\
192.168.15.5 interface=wg3 is-responder=yes name=peer6 preshared-key=\
"[REDACTED]" public-key=\
"[REDACTED]"
/ip address
add address=192.168.2.1/24 comment=defconf interface=bridge network=\
192.168.2.0
add address=192.168.20.3/24 interface=wg0 network=192.168.20.0
add address=192.168.30.3/24 interface=wg1 network=192.168.30.0
add address=192.168.10.2 interface=wg2 network=192.168.10.0
add address=192.168.15.1/24 interface=wg3 network=192.168.15.0
/ip dhcp-client
add add-default-route=no comment=defconf interface=ether1 use-peer-dns=no
/ip dhcp-server network
add address=192.168.2.0/24 comment=defconf dns-server=192.168.2.10 domain=\
local gateway=192.168.2.1 netmask=24
/ip dns
set allow-remote-requests=yes servers=172.64.36.1,172.64.36.2 use-doh-server=\
https://[REDACTED].cloudflare-gateway.com/dns-query verify-doh-cert=yes
/ip dns static
add address=192.168.2.1 comment=defconf name=gwd.lan
add address=162.159.0.0 name=[REDACTED].cloudflare-gateway.com
add address=162.159.0.0 name=[REDACTED].cloudflare-gateway.com
/ip firewall address-list
add address=192.168.2.10 list=dns-servers
add address=192.168.2.1 list=dns-servers
add address=192.168.1.2 list=dns-servers
add address=192.168.1.3 list=dns-servers
add address=192.168.1.4 list=dns-servers
add address=192.168.1.5 list=dns-servers
add address=192.168.20.1 list=dns-servers
add address=192.168.30.1 list=dns-servers
add address=192.168.15.0/24 list=wireguard-clients
/ip firewall filter
add action=accept chain=input comment="Allow Wireguard from All" dst-port=\
51821 log-prefix=WG_In protocol=udp
add action=accept chain=input comment=\
"defconf: accept established,related,untracked" connection-state=\
established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=\
invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment=\
"defconf: accept to local loopback (for CAPsMAN)" dst-address=127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
in-interface-list=!LAN log-prefix=drop-input
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
ipsec-policy=in,ipsec
add action=accept chain=forward in-interface=wg3
add action=accept chain=forward comment="wg rw to outside" in-interface=wg3 \
log=yes log-prefix=wg3_to_wg0 out-interface=wg0
add action=accept chain=forward comment="wg rw to outside" in-interface=wg3 \
log=yes log-prefix=wg3_to_ether1 out-interface-list=WAN
add action=accept chain=forward comment="defconf: accept out ipsec policy" \
ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
connection-state=established,related hw-offload=yes
add action=accept chain=forward comment=\
"defconf: accept established,related, untracked" connection-state=\
established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" \
connection-state=invalid
add action=drop chain=forward comment=\
"defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
connection-state=new in-interface-list=WAN
add action=drop chain=input dst-port=53 in-interface-list=WAN log=yes \
log-prefix=DNS_In protocol=udp
add action=drop chain=input dst-port=53 in-interface-list=WAN log=yes \
log-prefix=DNS_In protocol=tcp
add action=drop chain=forward dst-port=53 log=yes log-prefix=DNSBlock_Out \
out-interface-list=WAN protocol=tcp src-address-list=!dns-servers
add action=drop chain=forward dst-port=53 log=yes log-prefix=DNSBlock_Out \
out-interface-list=WAN protocol=udp src-address-list=!dns-servers
add action=drop chain=forward dst-port=53 log=yes log-prefix=DNSBlock_Out \
out-interface=wg0 protocol=udp src-address-list=!dns-servers
add action=accept chain=input comment="Allow DNS from Wireguard Users" \
dst-port=53 in-interface=wg3 protocol=udp
/ip firewall mangle
add action=change-mss chain=forward new-mss=clamp-to-pmtu out-interface=wg0 \
passthrough=yes protocol=tcp tcp-flags=syn
add action=change-mss chain=forward new-mss=clamp-to-pmtu out-interface=wg1 \
passthrough=yes protocol=tcp tcp-flags=syn
add action=change-mss chain=forward new-mss=clamp-to-pmtu out-interface=wg1 \
passthrough=yes protocol=tcp tcp-flags=syn
add action=change-mss chain=forward new-mss=clamp-to-pmtu out-interface=wg3 \
passthrough=yes protocol=tcp tcp-flags=syn
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
ipsec-policy=out,none out-interface-list=WAN
add action=dst-nat chain=dstnat dst-address-list=!dns-servers dst-port=53 \
in-interface-list=LAN log=yes log-prefix=DNS_Redir_DST_TCP protocol=tcp \
src-address-list=!dns-servers to-addresses=192.168.2.10 to-ports=53
add action=dst-nat chain=dstnat dst-address-list=!dns-servers dst-port=53 \
in-interface-list=LAN log=yes log-prefix=DNS_Redir_DST_UDP protocol=udp \
src-address-list=!dns-servers to-addresses=192.168.2.10 to-ports=53
add action=masquerade chain=srcnat dst-port=53 log=yes log-prefix=\
DNS_Redir_MASQ_UDP protocol=udp src-address-list=!dns-servers
/ip firewall raw
add action=drop chain=prerouting in-interface-list=WAN log=yes log-prefix=\
DNS_RAW_UDP port=53 protocol=udp
add action=drop chain=prerouting in-interface-list=WAN log=yes log-prefix=\
DNS_RAW_UDP port=53 protocol=tcp
/ip route
add dst-address=192.168.20.0/24 gateway=wg0
add comment=d1 dst-address=[wg2 remote server addr] gateway=ether1
add disabled=no distance=1 dst-address=0.0.0.0/1 gateway=wg0
add disabled=no distance=1 dst-address=128.0.0.0/1 gateway=wg0
add comment=vpn1 dst-address=[wg0 remote server addr] gateway=ether1
add comment=vpn2 dst-address=[wg1 remote server addr] gateway=ether1
add disabled=no distance=2 dst-address=0.0.0.0/1 gateway=wg1
add disabled=no distance=2 dst-address=128.0.0.0/1 gateway=wg1
add dst-address=192.168.1.0/24 gateway=wg2
add disabled=yes distance=10 dst-address=0.0.0.0/0 gateway=ether1
/system identity
set name=gwd.lan
/system ntp client servers
add address=time.cloudflare.com