Hello,
I've been struggling for quite some time trying to make WireGuard work with Cloudflare DNS. Despite trying various filter rules, I haven't been successful. I would greatly appreciate your expertise.
As I understand it, Cloudflare DNS must not be proxied to work with WireGuard.
My setup:
- Cloudflare DNS configuration (see image attached)
- RG5009 configuration
/interface bridge
add admin-mac=XX:XX:XX:XX:XX:XX auto-mac=no comment=defconf name=bridge-lan
/interface ethernet
set [ find default-name=ether1 ] comment=ether1-isp name=ether1-isp \
rx-flow-control=on tx-flow-control=on
set [ find default-name=ether2 ] rx-flow-control=on tx-flow-control=on
set [ find default-name=ether3 ] rx-flow-control=on tx-flow-control=on
set [ find default-name=ether4 ] rx-flow-control=on tx-flow-control=on
set [ find default-name=ether5 ] rx-flow-control=on tx-flow-control=on
set [ find default-name=ether6 ] rx-flow-control=on tx-flow-control=on
set [ find default-name=ether7 ] rx-flow-control=on tx-flow-control=on
set [ find default-name=ether8 ] rx-flow-control=on tx-flow-control=on
set [ find default-name=sfp-sfpplus1 ] rx-flow-control=on tx-flow-control=on
/interface wireguard
add comment=WireGuard listen-port=12313 mtu=1420 name=wireguard1
/interface list
add comment=defconf name=WAN
add comment=defconf name=LAN
add comment="Detect Internet" name=INTERNET
/ip pool
add comment=main_pool name=main_pool ranges=192.168.10.10-192.168.10.99
/ip dhcp-server
add address-pool=main_pool always-broadcast=yes comment=dhcp-server-lan \
interface=bridge-lan lease-time=5m name=dhcp-server-lan
/system logging action
set 0 memory-lines=500
set 1 disk-lines-per-file=500
/certificate settings
set crl-download=yes
/disk settings
set auto-media-interface=bridge-lan
/interface bridge port
add bridge=bridge-lan comment=defconf interface=ether2
add bridge=bridge-lan comment=defconf interface=ether3
add bridge=bridge-lan comment=defconf interface=ether4
add bridge=bridge-lan comment=defconf interface=ether5
add bridge=bridge-lan comment=defconf interface=ether6
add bridge=bridge-lan comment=defconf interface=ether7
add bridge=bridge-lan comment=defconf interface=ether8
add bridge=bridge-lan comment=defconf interface=sfp-sfpplus1
/ip neighbor discovery-settings
set discover-interface-list=LAN
/ipv6 settings
set disable-ipv6=yes
/interface detect-internet
set detect-interface-list=INTERNET
/interface list member
add comment=defconf interface=bridge-lan list=LAN
add comment=defconf interface=ether1-isp list=WAN
add comment="Detect Internet" interface=ether1-isp list=INTERNET
/interface ovpn-server server
add mac-address=XX:XX:XX:XX:XX:XX name=ovpn-server1
/interface wireguard peers
add allowed-address=192.168.5.2/28 comment=Auster interface=wireguard1 name=\
wg0 public-key="GwR7=" responder=\
yes
add allowed-address=192.168.5.4/28 comment="Moto Horacio" interface=\
wireguard1 name=wg2 public-key=\
"86MF=" responder=yes
add allowed-address=192.168.5.5/28 comment=Coetzee interface=wireguard1 name=\
wg3 public-key="QkAu=" responder=\
yes
add allowed-address=192.168.0.3/28 comment=FLUSHRO2 interface=wireguard1 \
name=wg1 public-key="bDIm=" \
responder=yes
/ip address
add address=192.168.10.1/25 comment=main-lan interface=bridge-lan network=\
192.168.10.0
add address=192.168.20.1/27 comment=iot interface=bridge-lan network=\
192.168.20.0
add address=192.168.5.1/28 comment=wireguard interface=wireguard1 network=\
192.168.5.0
/ip arp
add address=192.168.10.9 comment="Unifi AP3" interface=bridge-lan \
mac-address=XX:XX:XX:XX:XX:XX
add address=192.168.10.2 comment=CRS310 interface=bridge-lan mac-address=\
XX:XX:XX:XX:XX:XX
add address=192.168.10.7 comment="Unifi AP1" interface=bridge-lan \
mac-address=XX:XX:XX:XX:XX:XX
add address=192.168.10.3 comment=CRS304-A interface=bridge-lan mac-address=\
XX:XX:XX:XX:XX:XX
add address=192.168.20.11 comment="EcoWitt GW2000" interface=bridge-lan \
mac-address=XX:XX:XX:XX:XX:XX
add address=192.168.20.12 comment="EcoWitt Console" interface=bridge-lan \
mac-address=XX:XX:XX:XX:XX:XX
add address=192.168.20.20 comment="HikVision NVR" interface=bridge-lan \
mac-address=XX:XX:XX:XX:XX:XX
add address=192.168.20.21 comment="HikVision Cam1" interface=bridge-lan \
mac-address=XX:XX:XX:XX:XX:XX
add address=192.168.10.10 comment=PVE interface=bridge-lan mac-address=\
XX:XX:XX:XX:XX:XX
add address=192.168.10.126 comment=AdGuardHome interface=bridge-lan \
mac-address=XX:XX:XX:XX:XX:XX
/ip dhcp-client
add comment=Fibertel interface=ether1-isp use-peer-dns=no use-peer-ntp=no
/ip dhcp-server config
set store-leases-disk=30m
/ip dhcp-server lease
add address=192.168.10.46 client-id=XX:XX:XX:XX:XX:XX comment=\
Lenovo_Horacio_LAN mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.12 comment=SamsungTV_LAN mac-address=XX:XX:XX:XX:XX:XX \
server=dhcp-server-lan
add address=192.168.10.14 comment=FireTV_Living_LAN mac-address=\
XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.21 comment="\
\nPS4_LAN" mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.42 comment="HP Horacio LAN" mac-address=\
XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.47 comment=Lenovo_Horacio_WLAN mac-address=\
XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.48 comment=PC_Fran_LAN mac-addressXX:XX:XX:XX:XX:XX \
server=dhcp-server-lan
add address=192.168.10.60 comment="\
\nEasyWeather_WLAN" mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.72 client-id=XX:XX:XX:XX:XX:XX comment="S22 Soledad" \
mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.71 client-id=XX:XX:XX:XX:XX:XX comment="Luvi Redmi" \
mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.36 client-id=XX:XX:XX:XX:XX:XX comment=\
"Posible Dell Soledad" mac-address=XX:XX:XX:XX:XX:XX server=\
dhcp-server-lan
add address=192.168.10.43 client-id=XX:XX:XX:XX:XX:XX comment=\
"HP Horacio WLAN" mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.74 client-id=XX:XX:XX:XX:XX:XX comment="Iphone Fran" \
mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.73 client-id=XX:XX:XX:XX:XX:XX comment="S22 Soledad" \
mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.22 client-id=1:ac:89:95:3d:56:4b comment=PS4_WLAN \
mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.2 client-id=1:d4:1:c3:5f:d0:70 comment=CRS310 \
mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.76 client-id=XX:XX:XX:XX:XX:XX comment=\
"Moto Horacio" mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.70 client-id=XX:XX:XX:XX:XX:XX comment="Luvi Redmi" \
mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.3 client-id=XX:XX:XX:XX:XX:XX comment=CRS304-A \
mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
add address=192.168.10.77 client-id=XX:XX:XX:XX:XX:XX comment="Moto Horacio" \
mac-address=XX:XX:XX:XX:XX:XX1 server=dhcp-server-lan
add address=192.168.10.50 client-id=XX:XX:XX:XX:XX:XX comment=Marconi \
mac-address=XX:XX:XX:XX:XX:XX server=dhcp-server-lan
/ip dhcp-server network
add address=192.168.10.0/25 comment=main-network dns-server=192.168.10.1 \
domain=home.internal gateway=192.168.10.1 netmask=25
/ip dns
set allow-remote-requests=yes cache-max-ttl=1d mdns-repeat-ifaces=bridge-lan \
servers=192.168.10.126 verify-doh-cert=yes
/ip dns static
add address=192.168.10.1 comment=RB5009UG name=rb5009.home.internal type=A
add address=192.168.10.126 comment=AdguardHome name=adguard.home.internal \
type=A
add address=192.168.10.100 comment="AdguardHome Web" name=adguard.kansoit.com \
type=A
add address=192.168.10.2 comment=CRS310 name=crs310.home.internal type=A
add address=192.168.10.3 comment=CRS304-A name=crs304a.home.internal type=A
add address=192.168.10.6 comment="Unifi Controller" name=unifi.home.internal \
type=A
add address=192.168.10.100 comment="Unifi Controller Web" name=\
unifi.kansoit.com type=A
add address=192.168.10.7 comment="Unifi AP1" name=ap1.home.internal type=A
add address=192.168.10.9 comment="Unifi AP3" name=ap3.home.internal type=A
add address=192.168.10.100 comment=PVE name=pve.kansoit.com type=A
add address=192.168.20.2 comment="Home Assistant" name=domus.home.internal \
type=A
add address=192.168.20.3 comment=ZBX-CUPS-NUT name=vesta.home.internal type=A
add address=192.168.10.100 comment=NUT name=nut.kansoit.com type=A
add address=192.168.10.100 comment="Cups Print Server" name=cups.kansoit.com \
type=A
add address=192.168.20.6 comment="Nut UPS-APC" name=fulgora.home.internal \
type=A
add address=192.168.20.11 comment="EcoWitt GW2000" name=ecogw.home.internal \
type=A
add address=192.168.20.12 comment="EcoWitt Console" name=\
ecoconsole.home.internal type=A
add address=192.168.20.20 comment="HikVision NVR" name=nvr.home.internal \
type=A
add address=192.168.20.21 comment="HikVision Cam1" name=cam1.home.internal \
type=A
add address=192.168.10.100 comment=NPM name=npm.home.internal type=A
add address=192.168.10.100 comment="NPM Web" name=npm.kansoit.com type=A
add address=192.168.10.101 comment=Docker name=docker.home.internal type=A
/ip firewall filter
add action=accept chain=input comment="Allow WireGuard port" dst-port=12313 \
protocol=udp
add action=accept chain=input comment="Allow WireGuard Clients to access LAN" \
src-address=192.168.5.0/28 dst-address=192.168.10.0/27
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
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 nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
ipsec-policy=out,none out-interface-list=WAN
add action=src-nat chain=srcnat comment=\
"Force traffic to IoT-Lan to appear from gateway" dst-address=\
192.168.20.0/27 log-prefix=nat-iot src-address=192.168.10.0/25 \
to-addresses=192.168.20.1
add action=redirect chain=dstnat comment=\
"Redirect DNS Requests to Router IP - AdguardHome Hangs!" disabled=yes \
dst-port=53 log-prefix=redirect protocol=udp to-ports=53
add action=redirect chain=dstnat comment=\
"Redirect DNS Requests to Router IP - AdguardHome Hangs!" disabled=yes \
dst-port=53 log-prefix=redirect protocol=tcp to-ports=53
add action=dst-nat chain=dstnat comment=\
"Redirect External UDP DNS to AdGuard" dst-address-type=!local dst-port=\
53 protocol=udp src-address=!192.168.10.126 to-addresses=192.168.10.126 \
to-ports=53
add action=dst-nat chain=dstnat comment=\
"Redirect External TCP DNS to AdGuard" dst-address-type=!local dst-port=\
53 protocol=tcp src-address=!192.168.10.126 to-addresses=192.168.10.126 \
to-ports=53
/ip ipsec profile
set [ find default=yes ] dpd-interval=2m dpd-maximum-failures=5
/ip service
set telnet disabled=yes
set ftp disabled=yes
set www disabled=yes
set ssh address=192.168.10.0/25
set api disabled=yes
set winbox address=192.168.10.0/25
set api-ssl disabled=yes
/system ntp client
set enabled=yes
/system ntp client servers
add address=br.pool.ntp.org
add address=ar.pool.ntp.org
add address=cl.pool.ntp.org
- Client Configuration (Windows 11)
[Interface]
PrivateKey = QPGy=
Address = 192.168.5.3/24
DNS = 192.168.10.1
MTU = 1420
[Peer]
PublicKey = /QUM=
AllowedIPs = 0.0.0.0/0
Endpoint = wg.kan------.com:12313
This rule always gets traffic:
add action=accept chain=input comment="Allow WireGuard port" dst-port=12313 protocol=udp
This is an example using my phone (4G)
/tool sniffer quick port=12313
Columns: INTERFACE, TIME, NUM, DIR, SRC-MAC, DST-MAC, SRC-ADDRESS, DST-ADDRESS, PROTOCOL, SIZE, CPU
INTERFACE TIME NUM DIR SRC-MAC DST-MAC SRC-ADDRESS DST-ADDRESS PROTOCOL SIZE CPU
ether1-isp 36.025 15 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 154 0
ether1-isp 36.286 16 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 154 0
ether1-isp 37.066 17 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 154 0
ether1-isp 37.474 18 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 154 0
ether1-isp 38.235 19 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 154 0
ether1-isp 38.558 20 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 138 0
ether1-isp 39.238 21 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 106 0
ether1-isp 39.245 22 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 106 0
ether1-isp 39.245 23 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 106 0
ether1-isp 39.245 24 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 106 0
ether1-isp 39.245 25 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 106 0
ether1-isp 39.245 26 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 106 0
ether1-isp 42.383 27 -> XX:XX:XX:XX:F2:81 XX:XX:XX:XX:D8:19 24.XXX.XXX.XXX:12313 186.XXX.XXX.XX:33594 ip:udp 74 3
ether1-isp 43.251 28 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 154 0
ether1-isp 43.577 29 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 138 0
ether1-isp 48.267 30 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 154 0
ether1-isp 51.875 31 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 170 0
ether1-isp 53.258 32 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 154 0
ether1-isp 53.263 33 -> XX:XX:XX:XX:F2:81 XX:XX:XX:XX:D8:19 24.XXX.XXX.XXX:12313 186.XXX.XXX.XX:33594 ip:udp 74 3
ether1-isp 55.897 34 <- XX:XX:XX:XX:D8:19 XX:XX:XX:XX:F2:81 186.XXX.XXX.XX:33594 24.XXX.XXX.XXX:12313 ip:udp 170 0
But this one never gets any traffic:
add action=accept chain=input comment="Allow WireGuard Clients to access LAN" src-address=192.168.5.0/28 dst-address=192.168.10.0/27
I've also tried changing from "input" to "forward" and moving this rule down under the following rule, but without success:
add action=accept chain=input comment="defconf: accept established,related,untracked" connection-state=established,related,untracked
Any guidance would be much appreciated.
Thank you!