Configure DNS and verify router, client and browser
Outcome
Section titled “Outcome”You can answer three questions separately:
- Which upstream DNS server does the router use?
- Which DNS server does a client receive from OpenWrt?
- Does the browser bypass the system resolver with DoH?
And you can return to a resolving state after a failed change.
Applicable environment
Section titled “Applicable environment”- OpenWrt 25.12.6, default
dnsmasq+odhcpd; 25.12 usesapk, 24.10 usesopkg. - The inspection commands need no extra packages. If the device runs
unboundorhttps-dns-proxy, check whether it owns port 53 first. - Menu labels and config keys are close on 24.10, but package commands differ; do not copy
apkcommands into 24.10.
DNS path and responsibilities
Section titled “DNS path and responsibilities”| Location | Default owner | What to check |
|---|---|---|
| WAN upstream | DHCP/PPPoE client | cat /tmp/resolv.conf.d/resolv.conf.auto |
| Router resolver | dnsmasq |
nslookup openwrt.org 127.0.0.1 |
| LAN advertisement | dnsmasq DHCP option 6 / odhcpd RDNSS |
the DNS shown on a client |
| Browser | system resolver or browser DoH | the browser’s secure DNS setting |
Diagnose the layer before replacing DNS servers.
Before you change anything
Section titled “Before you change anything”cp /etc/config/dhcp /etc/config/dhcp.bak.$(date +%F)uci export dhcp > /tmp/dhcp.beforeuci show dhcp | grep -E 'dns|resolv|server|option'Keep a wired LAN path to LuCI/SSH. Do not make the only management path depend on the DNS you are changing.
ExpectedA backup exists and you know how to restore it.
Minimal steps
Section titled “Minimal steps”cat /tmp/resolv.conf.d/resolv.conf.autouci show dhcp.@dnsmasq[0]uci show network.wan | grep -E 'peerdns|dns'/tmp/resolv.conf.d/resolv.conf.auto is written by the WAN client. Check the actual dhcp.@dnsmasq[0].resolvfile value. If noresolv='1', dnsmasq ignores that file and uses its server list.
ExpectedYou can name the current resolvfile, server and noresolv values.
Open Network → Interfaces → WAN → Advanced Settings:
- Clear “Use DNS servers advertised by peer” (
peerdnsbecomes 0). - Add the DNS servers you trust under “Use custom DNS servers”, for example
1.1.1.1and9.9.9.9. - Save and apply, then reconnect WAN if needed.
This briefly interrupts WAN but leaves the LAN DHCP/DNS structure intact, which makes rollback easier.
ExpectedAfter reconnecting WAN, the upstream resolver is the value you set.
netstat -lnp | grep ':53'/etc/init.d/dnsmasq restartlogread -e dnsmasq | tail -20If dnsmasq fails to start, stop changing DHCP options. Use the error text to find a syntax error or port conflict.
ExpectedPort 53 is listening and the log has no config error.
Open Network → DHCP/DNS → DHCP Server → Advanced Settings and inspect “DHCP Options”. Without option 6, clients normally use the router LAN address as DNS. With option 6, they receive that address directly.
Do not point clients at an address that is not listening on port 53.
ExpectedThe client receives the OpenWrt LAN address, or the explicit option 6 you intended.
uci set network.wan.peerdns='0'uci -q delete network.wan.dnsuci add_list network.wan.dns='1.1.1.1'uci commit networkifup wancat /tmp/resolv.conf.d/resolv.conf.autoAfter the change, use logread -e dnsmasq to confirm the new upstream. If clients still receive the old DNS, restart dnsmasq or inspect DHCP option 6.
Expectedresolv.auto shows 1.1.1.1 and queries succeed.
Verify from clients
Section titled “Verify from clients”nslookup openwrt.org 127.0.0.1nslookup -type=AAAA openwrt.org 127.0.0.1ExpectedBoth queries return an answer without timing out.
Linux:
resolvectl statuscat /etc/resolv.confnslookup openwrt.orgWindows:
ipconfig /allnslookup openwrt.orgmacOS:
scutil --dnsnslookup openwrt.orgExpectedThe client DNS matches DHCP/static config and resolves a name.
Chrome/Edge: chrome://settings/security or “Privacy and security → Security → Use secure DNS”. Firefox: Settings → Privacy & Security → DNS over HTTPS. If DoH is on, the system resolver may not be used at all; that looks like “router DNS did not take effect”.
ExpectedDoH is off during the test, or you know exactly where it points.
nslookup -type=AAAA openwrt.orgip -6 routeDo not infer healthy IPv6 DNS from an IPv4 result when the upstream has no IPv6 prefix.
ExpectedAAAA resolves when IPv6 upstream exists; otherwise record the missing condition.
Failure branches and recovery
Section titled “Failure branches and recovery”Pages do not load, but IP ping works
Section titled “Pages do not load, but IP ping works”Suspect DNS first:
- Check the client resolver:
resolvectl status,ipconfig /all, orscutil --dns. - Check port 53 and dnsmasq logs on the router:
netstat -lnp | grep ':53',logread -e dnsmasq. - Check browser DoH and disable it temporarily.
- Check DHCP option 6 for a wrong address.
LuCI/SSH is unreachable
Section titled “LuCI/SSH is unreachable”Stop changing DNS. Connect a wired client to LAN, give it a static address in the same subnet, and confirm the gateway is the OpenWrt LAN address. Restore from console or SSH:
cp /etc/config/dhcp.bak.YYYY-MM-DD /etc/config/dhcpuci commit dhcp/etc/init.d/dnsmasq restartIf you changed WAN DNS, restore automatic upstream DNS:
uci set network.wan.peerdns='1'uci -q delete network.wan.dnsuci commit networkifup wanWAN DNS changed but clients still use the old resolver
Section titled “WAN DNS changed but clients still use the old resolver”Check whether resolv.auto changed, then whether dnsmasq loaded the new upstream:
cat /tmp/resolv.conf.d/resolv.conf.autologread -e dnsmasq | tail -20/etc/init.d/dnsmasq restartIf resolv.auto did not change, inspect network.wan.dns and peerdns. If clients still receive the old DNS, inspect DHCP option 6 and browser DoH.
dnsmasq does not start
Section titled “dnsmasq does not start”Read the error instead of restarting repeatedly:
logread -e dnsmasq | tail -50dnsmasq --testCommon causes are another resolver holding port 53, a syntax error, or an unreachable upstream. Restore the backup first, then reintroduce custom settings one at a time.
E2 lab run (2026-10-20)
Section titled “E2 lab run (2026-10-20)”- Environment: PVE 9.2.2 single NIC; OpenWrt 25.12.6 VM 200; WAN
192.168.50.77/24, LAN192.168.1.1/24. - Baseline:
resolv.autowasnameserver 192.168.50.1;nslookup openwrt.org 127.0.0.1returned A/AAAA. - Custom:
peerdns=0+network.wan.dns=1.1.1.1;resolv.autochanged tonameserver 1.1.1.1; queries still worked. - Failure: dnsmasq upstream set to unreachable
192.0.2.1; a random.example.comquery returnedconnection timed out; no servers could be reached; deletingnoresolv/serverand restoringpeerdns=1recovered resolution. - Client: netns DHCP received
192.168.1.116/24, DNS192.168.1.1;dig @192.168.1.1 openwrt.orgworked;ping 192.168.50.1worked. - Not tested: browser DoH, IPv6 upstream/RA/RDNSS, physical LAN clients, long-run stability.
Sources and review
Section titled “Sources and review”- This page has an E2 lab reproduction; browser DoH and IPv6 upstream are still untested and must not be described as verified.
- Evidence:
docs/dns-e2-run.mdandtests/recipes/dns-25.12-x86.md. - Update
testedVersionsandlastVerifiedAtwhen the menu or version changes; do not put 24.10opkgcommands into a 25.12 procedure.
Sources
Independent OpenWrt notes. Every page states the firmware, device, package manager and way back.
Icons: Solar by 480 Design, CC BY 4.0