Attempting to prevent hardcoded DNS from reaching its server and just redirect to local router resolution (unbound).
Following docs - https://openwrt.org/docs/guide-user/firewall/fw3_configurations/intercept_dns#web_interface_instructions
Setup and results:
PC. This is how default setup works, just redirect to local router DNS
> nslookup msn.com
Server: 192.168.1.1
Address: 192.168.1.1#53
Non-authoritative answer:
Name: msn.com
Address: 204.79.197.219
# Router
> tcpdump -i any port 53
03:04:18.309613 phy0-ap0 P IP 192.168.1.17.37829 > 192.168.1.1.53: 5568+ A? msn.com. (25)
03:04:18.309621 br-lan In IP 192.168.1.17.37829 > 192.168.1.1.53: 5568+ A? msn.com. (25)
03:04:18.311029 eth0 Out IP 172.31.2.249.45152 > ns4.demysdns.co.uk.53: 17912% [1au] A? msn.com. (36)
03:04:18.311089 eth0 Out IP 172.31.2.249.9426 > ns2-04.azure-dns.net.53: 65339% [1au] A? ns2-204.azure-dns.net. (50)
03:04:18.311144 eth0 Out IP 172.31.2.249.59229 > ns3-02.azure-dns.org.53: 12561% [1au] A? ns3-204.azure-dns.org. (50)
03:04:18.311194 eth0 Out IP 172.31.2.249.65500 > ns4-04.azure-dns.info.53: 38067% [1au] A? ns4-204.azure-dns.info. (51)
03:04:18.315722 eth0 In IP ns4.demysdns.co.uk.53 > 172.31.2.249.45152: 17912*- 1/0/1 A 204.79.197.219 (52)
03:04:18.315859 eth0 In IP ns2-04.azure-dns.net.53 > 172.31.2.249.9426: 65339*-$ 1/0/1 A 150.171.21.204 (66)
03:04:18.316208 eth0 In IP ns4-04.azure-dns.info.53 > 172.31.2.249.65500: 38067*-$ 1/0/1 A 208.84.5.204 (67)
03:04:18.316286 eth0 In IP ns3-02.azure-dns.org.53 > 172.31.2.249.59229: 12561*-$ 1/0/1 A 204.14.183.204 (66)
03:04:18.316349 eth0 Out IP 172.31.2.249.42910 > e.gtld-servers.net.53: 5437% [1au] DS? msn.com. (36)
03:04:18.321035 eth0 In IP e.gtld-servers.net.53 > 172.31.2.249.42910: 5437*- 0/6/1 (565)
03:04:18.324118 br-lan Out IP 192.168.1.1.53 > 192.168.1.17.37829: 5568 1/0/0 A 204.79.197.219 (41)
03:04:18.324134 phy0-ap0 Out IP 192.168.1.1.53 > 192.168.1.17.37829: 5568 1/0/0 A 204.79.197.219 (41)
03:04:18.326559 phy0-ap0 P IP 192.168.1.17.53561 > 192.168.1.1.53: 34166+ AAAA? msn.com. (25)
firewall setting attempt 1:
config redirect
option target 'DNAT'
option name 'Redirect DNS'
option family 'ipv4'
option src 'lan'
option src_dport '53'
option dest_ip '192.168.1.1'
option dest_port '53'
option dest 'wan'
PC, if we try to force DNS (it does not redirect to local router DNS)
> nslookup msn.com 8.8.8.8
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
Name: msn.com
Address: 204.79.197.219
Router
> tcpdump -i any port 53
03:06:09.631941 phy0-ap0 P IP 192.168.1.17.35837 > dns.google.53: 37977+ A? msn.com. (25)
03:06:09.631949 br-lan In IP 192.168.1.17.35837 > dns.google.53: 37977+ A? msn.com. (25)
03:06:09.632715 br-lan Out IP dns.google.53 > 192.168.1.17.35837: 37977 1/0/0 A 204.79.197.219 (41)
03:06:09.632725 phy0-ap0 Out IP dns.google.53 > 192.168.1.17.35837: 37977 1/0/0 A 204.79.197.219 (41)
03:06:09.635083 phy0-ap0 P IP 192.168.1.17.53382 > dns.google.53: 63907+ AAAA? msn.com. (25)
03:06:09.635091 br-lan In IP 192.168.1.17.53382 > dns.google.53: 63907+ AAAA? msn.com. (25)
03:06:09.635792 br-lan Out IP dns.google.53 > 192.168.1.17.53382: 63907 0/1/0 (90)
03:06:09.635802 phy0-ap0 Out IP dns.google.53 > 192.168.1.17.53382: 63907 0/1/0 (90)
firewall setting attempt 2:
config redirect
option target 'DNAT'
option name 'Redirect DNS'
option family 'ipv4'
option src 'lan'
option src_dport '53'
option dest_ip '192.168.1.1'
option dest_port '53'
- Interesting note, if we follow openwrt docs, setting unspecified in destination zone will default to
LAN-Section @redirect[0] (Redirect DNS) does not specify a destination, assuming 'lan'
Router
> tcpdump -i any port 53
03:13:45.211612 phy0-ap0 P IP 192.168.1.17.59031 > dns.google.53: 9166+ A? msn.com. (25)
03:13:45.211620 br-lan In IP 192.168.1.17.59031 > dns.google.53: 9166+ A? msn.com. (25)
03:13:45.212388 br-lan Out IP dns.google.53 > 192.168.1.17.59031: 9166 1/0/0 A 204.79.197.219 (41)
03:13:45.212397 phy0-ap0 Out IP dns.google.53 > 192.168.1.17.59031: 9166 1/0/0 A 204.79.197.219 (41)
03:13:45.214669 phy0-ap0 P IP 192.168.1.17.43075 > dns.google.53: 20830+ AAAA? msn.com. (25)
03:13:45.214674 br-lan In IP 192.168.1.17.43075 > dns.google.53: 20830+ AAAA? msn.com. (25)
03:13:45.215152 br-lan Out IP dns.google.53 > 192.168.1.17.43075: 20830 0/1/0 (90)
03:13:45.215157 phy0-ap0 Out IP dns.google.53 > 192.168.1.17.43075: 20830 0/1/0 (90)
03:13:45.226523 lo In IP localhost.45033 > localhost.53: 56170+ PTR? 8.8.8.8.in-addr.arpa. (38)
03:13:45.227367 lo In IP localhost.53 > localhost.45033: 56170 1/0/0 PTR dns.google. (62)
03:13:45.227775 lo In IP localhost.52943 > localhost.53: 22788+ PTR? 17.1.168.192.in-addr.arpa. (43)
03:13:45.228482 lo In IP localhost.53 > localhost.52943: 22788 NXDomain 0/1/0 (127)
Router
> cat /etc/openwrt_release
DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='24.10.2'
DISTRIB_REVISION='r28739-d9340319c6'
DISTRIB_TARGET='x86/64'
DISTRIB_ARCH='x86_64'
DISTRIB_DESCRIPTION='OpenWrt 24.10.2 r28739-d9340319c6'
DISTRIB_TAINTS=''
Confused why it goes to dns.google.53 despite the firewall setting, any idea?