Small summary: I have a physical decentralized VPN device (on eth2-dvpn) between the router and the modem. It is “transparent,” and the IP on the interface is 10.10.10.3 with a gateway of 10.10.10.1.
On eth5-publicip, I have a direct link to my modem, with the IP 10.10.10.5 and gateway 10.10.10.1.
I also have a NordVPN tunnel on 10.5.0.0/24, which uses eth2-dvpn for its outbound connection.
Lastly, I use mangle rules to determine which packets should use which port.
Everything works well, but issues arise with another WireGuard tunnel. It works only if I add a static route to my smartphone’s IP, which uses eth2-dvpn. It does not work through the WireGuard NordVPN tunnel (which is the main routing table).
A strange thing happens: if I add the smartphone’s IP to the “list-dVPN-sites,” it does not work. Similarly, the NordVPN endpoint IP requires a static route, but this route never changes, while the smartphone’s IP does.
I have tried using connection marking on input and route marking (by marked connection) on output, but still no luck (refer to the first four disabled mangle rules for the attempts).
My question is how to route the outbound connection from wireguard-private (and also from wireguard-nordvpn, where the problem is less significant because the endpoint has a static IP) to eth2.
You can see both static routing rules in the main routing table, if i deactivate it, no handshake.
Here my config (Don’t worry about the firewall; I disable it during testing) and remember, i have 3 ip (public, dvpn, nordvpn), wireguard-private works if i connect to my public ip, and the router replies on the eth-2 or eth-5 (not via nordvpn)
# model = RB951Ui-2nD
#
/interface bridge
add name=bridge-trunk port-cost-mode=short vlan-filtering=yes
/interface ethernet
set [ find default-name=ether1 ] name=ether1-trunk
set [ find default-name=ether2 ] name=ether2-dVPN
set [ find default-name=ether3 ] name=ether3-10gar
set [ find default-name=ether4 ] name=ether4-10gar
set [ find default-name=ether5 ] name=ether5-publicIP poe-out=off
/interface wireguard
add listen-port=51820 mtu=1420 name=wireguard-nordVPN
add listen-port=51821 mtu=1420 name=wireguard-private
/interface vlan
add interface=bridge-trunk name=vlan10-gar vlan-id=10
add interface=bridge-trunk name=vlan50-iot vlan-id=50
/ip dhcp-server
add add-arp=yes interface=vlan50-iot lease-time=1d name=dhcp-iot
add address-pool=pool-gar interface=vlan10-gar lease-time=1d name=dhcp-gar
add address-pool=pool-trunk interface=bridge-trunk lease-time=1d name=\
dhcp-trunk
/routing table
add disabled=no fib name=public
add disabled=no fib name=dVPN
/interface bridge port
add bridge=bridge-trunk interface=ether1-trunk internal-path-cost=10 \
path-cost=10
add bridge=bridge-trunk interface=ether3-10gar internal-path-cost=10 \
path-cost=10 pvid=10
add bridge=bridge-trunk interface=ether4-10gar internal-path-cost=10 \
path-cost=10 pvid=10
add bridge=bridge-trunk interface=wlan10-gar internal-path-cost=10 path-cost=\
10 pvid=10
add bridge=bridge-trunk interface=wlan20-dau internal-path-cost=10 path-cost=\
10 pvid=20
add bridge=bridge-trunk interface=wlan66-666 internal-path-cost=10 path-cost=\
10 pvid=66
add bridge=bridge-trunk interface=wlan90-guest internal-path-cost=10 \
path-cost=10 pvid=90
add bridge=bridge-trunk interface=wlan50-iot internal-path-cost=10 path-cost=\
10 pvid=50
add bridge=bridge-trunk interface=wlan30-cas internal-path-cost=10 path-cost=\
10 pvid=30
/interface bridge vlan
add bridge=bridge-trunk tagged=bridge-trunk,ether1-trunk untagged=\
ether3-10gar,ether4-10gar,wlan10-gar vlan-ids=10
add bridge=bridge-trunk tagged=bridge-trunk,ether1-trunk untagged=wlan20-dau \
vlan-ids=20
add bridge=bridge-trunk tagged=bridge-trunk,ether1-trunk untagged=wlan30-cas \
vlan-ids=30
add bridge=bridge-trunk tagged=bridge-trunk,ether1-trunk untagged=wlan50-iot \
vlan-ids=50
add bridge=bridge-trunk tagged=bridge-trunk,ether1-trunk untagged=\
wlan90-guest vlan-ids=90
add bridge=bridge-trunk untagged=ether1-trunk,bridge-trunk vlan-ids=1
add bridge=bridge-trunk tagged=bridge-trunk,ether1-trunk untagged=wlan66-666 \
vlan-ids=66
/interface list member
add interface=ether2-dVPN list=list-wan&vpn
add interface=ether5-publicIP list=list-wan&vpn
add interface=wireguard-nordVPN list=list-wan&vpn
add interface=wireguard-private list=list-wan&vpn
/interface wireguard peers
add allowed-address=0.0.0.0/0,::/0 client-address=10.2.2.2/32 interface=\
wireguard-private name=peer-smartphone public-key=\
"REDACTED"
add allowed-address=0.0.0.0/0,::/0 endpoint-address=85.190.232.140 \
endpoint-port=51820 interface=wireguard-nordVPN name=peer-nordVPN \
persistent-keepalive=25s public-key=\
"REDACTED"
/ip address
add address=192.168.10.1/24 interface=vlan10-gar network=192.168.10.0
add address=192.168.50.1/24 interface=vlan50-iot network=192.168.50.0
add address=10.1.1.1/29 interface=bridge-trunk network=10.1.1.0
add address=10.5.0.2/24 interface=wireguard-nordVPN network=10.5.0.0
add address=10.2.2.1/24 comment=vpn-private interface=wireguard-private \
network=10.2.2.0
/ip dhcp-client
add add-default-route=no interface=ether2-dVPN use-peer-dns=no
add add-default-route=no interface=ether5-publicIP use-peer-dns=no
/ip dhcp-server network
add address=10.1.1.0/29 comment=trunk gateway=10.1.1.1 netmask=29
add address=192.168.10.0/24 dns-server=10.1.1.1 gateway=192.168.10.1
add address=192.168.50.0/24 dns-server=10.1.1.1 gateway=192.168.50.1
/ip dns
set allow-remote-requests=yes servers=103.86.96.100,103.86.99.100,1.1.1.1
/ip firewall address-list
add address=mypersonalip.com list=list-dVPN-sites
add address=www.snapchat.com list=list-blockedsites
add address=192.168.10.0/24 list=list-Internal-networks
add address=192.168.20.0/24 list=list-Internal-networks
add address=192.168.30.0/24 list=list-Internal-networks
add address=192.168.50.0/24 list=list-Internal-networks
add address=10.11.11.0/24 comment=guest list=list-Internal-networks
add address=192.168.66.0/24 list=list-Internal-networks
add address=10.1.1.0/29 comment=trunk list=list-Internal-networks
add address=api.ipify.org list=list-publicIPsites
add address=10.2.2.0/24 comment="vpn private" list=list-Internal-networks
add address=10.2.2.0/24 list=list-ioT-toWireguard&InterVlan
add address=192.168.10.0/24 list=list-ioT-toWireguard&InterVlan
add address=10.1.1.1 list=list-ioT-toWireguard&InterVlan
add address=beb-dvr.hass list=list-publicIPclients
add address=gar-dvr.hass list=list-publicIPclients
add address=gar-inverter.hass list=list-publicIPclients
add address=beb-inverter.hass list=list-publicIPclients
add address=homeassistant.hass list=list-publicIPclients
add address=34.34.34.34 list=list-dVPN-sites
add address=it270.nordvpn.com disabled=yes list=list-dVPN-sites
add address=ipinfo.io list=list-dVPN-sites
add address=10.10.10.1 comment=vodafone list=list-Internal-networks
add address=10.10.10.5 list=list-Internal-networks
add address=10.5.0.0/24 comment=nordVPN list=list-Internal-networks
add address=10.10.10.3 list=list-Internal-networks
add address=beb-pompa.hass list=list-ioT-tointernet
add address=10.5.0.1 list=list-ioT-toWireguard&InterVlan
add address=ifconfig.me list=list-publicIPsites
add address=93.150.221.0/24 comment="endpoint SMARTPHONE wireg vpn" list=\
list-dVPN-sites
/ip firewall mangle
add action=mark-connection chain=input comment=\
"ConnTrack wireguard-private peers to dVPN" disabled=yes dst-port=51821 \
log-prefix=wireguardaccept new-connection-mark=mark-wireguard-private \
passthrough=no protocol=udp src-address-list=!list-Internal-networks
add action=mark-connection chain=prerouting comment="mark connTrack" \
disabled=yes dst-port=51821 log-prefix=packetmark new-connection-mark=\
mark-wireguard-private passthrough=no protocol=udp
add action=mark-connection chain=output comment="mark connTrack" disabled=yes \
log-prefix=packetmarkAAAAA new-connection-mark=mark-wireguard-private \
out-interface=wireguard-private passthrough=yes
add action=mark-routing chain=output comment="mark connTrack" \
connection-mark=mark-wireguard-private disabled=yes log-prefix=\
packetmarkAAAAA new-routing-mark=public passthrough=no
add action=mark-routing chain=prerouting comment=\
"VISIT WEBSITES with dVPN IP" dst-address-list=list-dVPN-sites \
log-prefix="mark dvpn" new-routing-mark=dVPN passthrough=no \
src-address-list=list-Internal-networks
add action=mark-routing chain=output comment=\
"VISIT WEBSITES with dVPN IP (R1-GAR)" dst-address-list=list-dVPN-sites \
log-prefix=publicWebsite new-routing-mark=dVPN out-interface-list=\
list-wan&vpn passthrough=no
add action=mark-routing chain=prerouting comment=\
"VISIT WEBSITES with publicIP" dst-address-list=list-publicIPsites \
log-prefix=publicIPsite new-routing-mark=public passthrough=no \
src-address-list=list-Internal-networks
add action=mark-routing chain=output comment=\
"VISIT WEBSITES with publicIP (R1-GAR)" dst-address-list=\
list-publicIPsites log-prefix=publicWebsite new-routing-mark=public \
out-interface-list=list-wan&vpn passthrough=no
add action=mark-routing chain=prerouting comment=\
"CLIENTS GO OUT with public IP" dst-address-list=!list-Internal-networks \
log-prefix="mark homeAss Public IP when need go to net" new-routing-mark=\
public passthrough=no src-address-list=list-publicIPclients
add action=mark-routing chain=prerouting comment=\
"vlan666 (TOS26) to public routing table " dscp=26 new-routing-mark=\
public passthrough=no
/ip firewall nat
add action=masquerade chain=srcnat dst-address=0.0.0.0/0 out-interface-list=\
list-wan&vpn
/ip route
add comment="dVPN Gateway" disabled=no distance=20 dst-address=0.0.0.0/0 \
gateway=10.10.10.1%ether2-dVPN pref-src="" routing-table=main scope=30 \
suppress-hw-offload=no target-scope=10 vrf-interface=ether2-dVPN
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
10.10.10.1%ether5-publicIP routing-table=public suppress-hw-offload=no
add disabled=no distance=1 dst-address=10.10.10.0/24 gateway=ether5-publicIP \
routing-table=public scope=10 suppress-hw-offload=no
add check-gateway=ping comment="nordVPN Gateway" disabled=no distance=10 \
dst-address=0.0.0.0/0 gateway=10.5.0.1 routing-table=main scope=30 \
suppress-hw-offload=no target-scope=10
add comment="it nordvpn endpoint POOL route outside Tunnel" disabled=no distance=5 \
dst-address=85.190.232.0/24 gateway=10.10.10.1%ether2-dVPN routing-table=\
main scope=30 suppress-hw-offload=no target-scope=10
add comment="ALL PUBLIC" disabled=no distance=30 dst-address=0.0.0.0/0 \
gateway=10.10.10.1%ether5-publicIP routing-table=main scope=30 \
suppress-hw-offload=no target-scope=10
add disabled=no distance=1 dst-address=10.10.10.0/24 gateway=ether2-dVPN \
routing-table=dVPN scope=10 suppress-hw-offload=no target-scope=10
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
10.10.10.1%ether2-dVPN routing-table=dVPN scope=30 suppress-hw-offload=no \
target-scope=10
add disabled=no distance=1 dst-address=10.1.1.0/29 gateway=bridge-trunk \
routing-table=dVPN scope=10 suppress-hw-offload=no
add disabled=no distance=10 dst-address=10.1.1.0/29 gateway=bridge-trunk \
routing-table=public scope=10 suppress-hw-offload=no
add comment="SMARTPHONE wireg-private endpoint outside tunnel" disabled=no distance=5 dst-address=\
93.150.221.0/24 gateway=10.10.10.1%ether2-dVPN routing-table=main scope=\
30 suppress-hw-offload=no target-scope=10
add disabled=no distance=1 dst-address=10.2.2.0/24 gateway=wireguard-private \
routing-table=dVPN scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=1 dst-address=10.5.0.0/24 gateway=wireguard-nordVPN \
routing-table=dVPN scope=10 suppress-hw-offload=no target-scope=5
/routing rule
add action=lookup-only-in-table disabled=no routing-mark=public table=public
add action=lookup-only-in-table disabled=no routing-mark=dVPN table=dVPN
add action=lookup-only-in-table disabled=no interface=bridge-trunk table=main
