I have tried for a couple of days now to figure out the correct setting for this. Looked at lots of the guides and videos (everything I have seen seems to be v6 not v7 guides) about WireGuard setups but can’t seem to get this last step to work.
I have a server setup from vultr.com with a public IP running ubuntu with WireGuard installed. It’s configured to masquerade all traffic from public ip down the WireGuard tunnel and back out the public IP . This works using windows client or phone to provide some kind of service. using iperf3 to test as server and client connections.
XX.XX.XX.82 is the public ip on the server
10.66.66.1 is the wg ip on the server
10.66.66.2 is the wg ip on the HAP AC2
192.168.1.1 is the isp router with CG-NAT
HAP AC2 is default configuration with just the wireguard setup added to it.
I have no problem getting WireGuard connected on the HAP AC2. The only issue with it is I can not get it to properly send response packets back into the WireGuard tunnel while its default route is the WAN interface.
Have “disabled=no distance=2 dst-address=0.0.0.0/0 gateway=192.168.1.1 routing-table=main” for the default route.
If i add any other routing tables and add dst-address=0.0.0.0/0 gateway=wg routing-table=wg_table it blocks all traffic out. If routing-table is set to main all traffic goes out the wg tunnel and response packets then get through of course just fine but I don’t want to all of it going down the vpn. I just need one device (camera DVR system) behind the HAP AC2 to be accessible on local lan and vpn ip.
I tried using step 3 https://forum.mikrotik.com/viewtopic.php?t=182340 and similar from other guides but as soon as i try adding the “dst-address=0.0.0.0/0 gwy=wg-interface-name table=use-WG” it looses all other connections.
/routing table add fib name=use-WG
/routing rule add src-address=IP address action=lookup-only-in-table table=use-WG
/ip route
dst-address=0.0.0.0/0 gwy=wg-interface-name table=use-WG
I have a few mangle rules and nat to try and force it with/without using the routing table (trying to mark vpn connections so return packets go vpn tunnel). first data stream of iperf3 works then the rest is lost.
I don’t get how to use the NAT rules and the route List/routing table. What am I missing?
Thank You.
Here is my current config.
# 2023-07-07 11:56:06 by RouterOS 7.10.1
# software id = DGII-IL3C
#
# model = RBD52G-5HacD2HnD
# serial number = ********
/interface bridge
add admin-mac=****** auto-mac=no comment=defconf name=bridge
/interface wireless
set [ find default-name=wlan1 ] band=2ghz-b/g/n channel-width=20/40mhz-XX \
disabled=no distance=indoors frequency=auto installation=indoor mode=\
ap-bridge ssid=MikroTik-955E7D wireless-protocol=802.11
set [ find default-name=wlan2 ] band=5ghz-a/n/ac channel-width=\
20/40/80mhz-XXXX disabled=no distance=indoors frequency=auto \
installation=indoor mode=ap-bridge ssid=MikroTik-955E7E \
wireless-protocol=802.11
/interface wireguard
add listen-port=52498 mtu=1420 name=wg
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip hotspot profile
set [ find default=yes ] html-directory=hotspot
/ip pool
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
/ip dhcp-server
add address-pool=default-dhcp interface=bridge lease-time=10m name=defconf
/routing table
add disabled=no fib name=wg_table
add disabled=no name=list
/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=wlan1
add bridge=bridge comment=defconf interface=wlan2
/ip neighbor discovery-settings
set discover-interface-list=LAN
/interface list member
add comment=defconf interface=bridge list=LAN
add comment=defconf interface=ether1 list=WAN
/interface wireguard peers
add allowed-address=10.66.66.0/24,0.0.0.0/0,::/0 endpoint-address=\
XX.XX.XX.82 endpoint-port=52498 interface=wg persistent-keepalive=25s \
public-key=""
/ip address
add address=192.168.88.1/24 comment=defconf interface=bridge network=\
192.168.88.0
add address=10.66.66.2/24 interface=wg network=10.66.66.0
/ip dhcp-client
add add-default-route=no comment=defconf interface=ether1
/ip dhcp-server network
add address=192.168.88.0/24 comment=defconf dns-server=192.168.88.1 gateway=\
192.168.88.1
/ip dns
set allow-remote-requests=yes servers=1.1.1.1,8.8.8.8
/ip dns static
add address=192.168.88.1 comment=defconf name=router.lan
/ip firewall filter
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=accept chain=input disabled=yes src-address=10.66.66.2
add action=drop chain=input comment="defconf: drop all not coming from LAN" \
in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" \
ipsec-policy=in,ipsec
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
/ip firewall mangle
add action=mark-packet chain=prerouting in-interface=wg new-packet-mark=vpn_p \
passthrough=yes
add action=mark-connection chain=prerouting in-interface=wg \
new-connection-mark=vpn_con passthrough=yes
add action=log chain=prerouting connection-mark=vpn_con disabled=yes log=yes \
log-prefix=tt
add action=route chain=prerouting connection-mark=vpn_con disabled=yes \
in-interface=bridge passthrough=yes route-dst=10.66.66.1
add action=fasttrack-connection chain=prerouting disabled=yes in-interface=\
bridge src-address-list=vpn_add_list
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
ipsec-policy=out,none out-interface-list=WAN
add action=masquerade chain=srcnat disabled=yes out-interface=wg \
routing-mark=wg_table to-addresses=192.168.88.254
add action=return chain=srcnat disabled=yes routing-mark=wg_table \
to-addresses=0.0.0.0/0
add action=masquerade chain=srcnat disabled=yes packet-mark=vpn_p
add action=masquerade chain=srcnat disabled=yes src-address-list=vpn_add_list
add action=masquerade chain=srcnat out-interface=wg
add action=dst-nat chain=dstnat dst-port=5201 protocol=tcp to-addresses=\
192.168.88.254 to-ports=5201
/ip route
add disabled=no distance=1 dst-address=XX.XX.XX.82/32 gateway=192.168.1.1 \
pref-src="" routing-table=main scope=30 suppress-hw-offload=no \
target-scope=10
add disabled=yes distance=1 dst-address=0.0.0.0/0 gateway=wg pref-src="" \
routing-table=main scope=30 suppress-hw-offload=no target-scope=10
add disabled=no distance=2 dst-address=0.0.0.0/0 gateway=192.168.1.1 \
pref-src="" routing-table=main scope=30 suppress-hw-offload=no \
target-scope=10
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=10.66.66.1 pref-src=\
"" routing-table=wg_table scope=30 suppress-hw-offload=no target-scope=10
add disabled=no dst-address=10.66.66.0/24 gateway=10.66.66.1 routing-table=\
main suppress-hw-offload=no
add disabled=yes distance=2 dst-address=0.0.0.0/0 gateway=10.66.66.1 \
pref-src="" routing-table=wg_table scope=30 suppress-hw-offload=no \
target-scope=10
add disabled=yes distance=1 dst-address=0.0.0.0/0 gateway=10.66.66.1 \
pref-src="" routing-table=wg_table scope=30 suppress-hw-offload=no \
target-scope=10
add disabled=yes distance=1 dst-address=0.0.0.0/0 gateway=wg pref-src="" \
routing-table=wg_table scope=30 suppress-hw-offload=no target-scope=10
add disabled=yes distance=1 dst-address=0.0.0.0/0 gateway=wg pref-src="" \
routing-table=wg_table scope=30 suppress-hw-offload=no target-scope=10
add disabled=yes distance=1 dst-address=0.0.0.0/0 gateway=wg pref-src="" \
routing-table=wg_table scope=30 suppress-hw-offload=no target-scope=10
add disabled=yes distance=1 dst-address=0.0.0.0/0 gateway=wg pref-src="" \
routing-table=list scope=30 suppress-hw-offload=no target-scope=10
/ipv6 firewall address-list
add address=::/128 comment="defconf: unspecified address" list=bad_ipv6
add address=::1/128 comment="defconf: lo" list=bad_ipv6
add address=fec0::/10 comment="defconf: site-local" list=bad_ipv6
add address=::ffff:0.0.0.0/96 comment="defconf: ipv4-mapped" list=bad_ipv6
add address=::/96 comment="defconf: ipv4 compat" list=bad_ipv6
add address=100::/64 comment="defconf: discard only " list=bad_ipv6
add address=2001:db8::/32 comment="defconf: documentation" list=bad_ipv6
add address=2001:10::/28 comment="defconf: ORCHID" list=bad_ipv6
add address=3ffe::/16 comment="defconf: 6bone" list=bad_ipv6
/ipv6 firewall filter
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 ICMPv6" protocol=\
icmpv6
add action=accept chain=input comment="defconf: accept UDP traceroute" port=\
33434-33534 protocol=udp
add action=accept chain=input comment=\
"defconf: accept DHCPv6-Client prefix delegation." dst-port=546 protocol=\
udp src-address=fe80::/10
add action=accept chain=input comment="defconf: accept IKE" dst-port=500,4500 \
protocol=udp
add action=accept chain=input comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=input comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=input comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=input comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
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 packets with bad src ipv6" src-address-list=bad_ipv6
add action=drop chain=forward comment=\
"defconf: drop packets with bad dst ipv6" dst-address-list=bad_ipv6
add action=drop chain=forward comment="defconf: rfc4890 drop hop-limit=1" \
hop-limit=equal:1 protocol=icmpv6
add action=accept chain=forward comment="defconf: accept ICMPv6" protocol=\
icmpv6
add action=accept chain=forward comment="defconf: accept HIP" protocol=139
add action=accept chain=forward comment="defconf: accept IKE" dst-port=\
500,4500 protocol=udp
add action=accept chain=forward comment="defconf: accept ipsec AH" protocol=\
ipsec-ah
add action=accept chain=forward comment="defconf: accept ipsec ESP" protocol=\
ipsec-esp
add action=accept chain=forward comment=\
"defconf: accept all that matches ipsec policy" ipsec-policy=in,ipsec
add action=drop chain=forward comment=\
"defconf: drop everything else not coming from LAN" in-interface-list=\
!LAN
/routing rule
add action=lookup disabled=yes routing-mark=wg_table src-address=0.0.0.0/0 \
table=wg_table
add action=lookup disabled=yes dst-address=10.66.66.1/32 interface=wg \
routing-mark=wg_table table=wg_table
add action=lookup disabled=yes dst-address=0.0.0.0/0 min-prefix=0 \
src-address=192.168.88.254/32 table=wg_table
add action=lookup-only-in-table disabled=yes min-prefix=0 src-address=\
192.168.88.253/32 table=wg_table
/system clock
set time-zone-name=America/Chicago
/system note
set show-at-login=no
/tool mac-server
set allowed-interface-list=LAN
/tool mac-server mac-winbox
set allowed-interface-list=LAN