Skip to content

dns: dnsmasq, mr-proxy-dns and mr-parental-dns listen on the LAN bridges and 127.0.0.1 / ::1 only, not on every address of lo (Closes #178) - #179

Merged
Cd1s merged 1 commit into
mainfrom
fix/dnsmasq-listen-scope
Oct 25, 2026
Merged

Cd1s merged 1 commit into
mainfrom
fix/dnsmasq-listen-scope

Conversation

@Cd1s

@Cd1s Cd1s commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

What

The main dnsmasq, mr-proxy-dns and mr-parental-dns now render

interface=<bridge>        # unchanged, one per LAN bridge
except-interface=lo
bind-dynamic
listen-address=127.0.0.1
listen-address=::1

(one shared constant, dnsmasqListenLines in mod_dns.go). They listen on the LAN bridges, 127.0.0.1 and ::1, and on no other address of lo.

Why

dnsmasq adds all of lo as soon as there is an interface= line, and bind-dynamic opens a UDP and a TCP socket for every address on it. An add-on that keeps hundreds of /128 source addresses on lo (twice as many while the ISP's prefix changes) ran all three instances into their 1024-descriptor limit: no DNS, mr proxy check failing, and so the migration that would drop the old addresses never finished. Closes #178.

listen-address overrides except-interface for the address it names (checked with dnsmasq 2.91 on the build host and 2.92 in the lab), so 127.0.0.1 / ::1 stay. bind-dynamic stays, so the bridges' addresses still follow the delegated prefix. Nothing else changes: dns.redirect, the proxy's and parental's nft redirects (they redirect to the bridge address), RDNSS (router's bridge address), DHCP (interface=), local-service, rebind protection and /etc/resolv.conf (127.0.0.1) are as before.

Verification

  • Go: TestDnsmasqListensOnBridgesAndLoopbackOnly (all three configs, two bridges: interface= lines are exactly the bridges, except-interface=lo, listen-address= exactly 127.0.0.1 and ::1, no bind-interfaces), TestDNSHomeDnsmasqUnchanged updated. TestIPv6RelayDisabledMatchesMainBaselineFiles pins a hash of the home dnsmasq.conf; I updated that hash for the three new lines (the old one was the origin/main baseline of that config).
  • tools/ci.d/dns.sh: the rendered lab dnsmasq runs for real with 1000 extra /128 on lo: 24 descriptors, listens on 127.0.0.1:53. tools/ci.d/proxy.sh: same for the rendered proxy-dns.conf and the main stand-in (15 and 22 descriptors).
  • Lab scenario 16-dnsmasq-listen-scope (new, lab id 8): PPPoE + DHCPv6-PD router with proxy, parental control and dns.redirect; three LAN clients (parental, proxied, bypass). 1000 /128 on lo under running dnsmasq, again after restarting all three, again after removing them: descriptors stay 21 / 18 / 17 (main / proxy / parental) in every phase; IPv4 and IPv6 DNS, redirect of port 53, safe search, blocklist, fake-ip answers, rebind protection, the router's own resolver (127.0.0.1 and ::1), mr proxy check, DHCP and a br-lan address added later (bind-dynamic) all pass: 103/103 ok.
  • The same scenario against origin/main (before the fix): 1024 descriptors in all three instances once the addresses are on lo, DNS down for every client, and no dnsmasq process was left 3 s after restarting them with the addresses present, nor after the addresses were removed again (41 ok / 62 not ok).
  • sh tools/ci.sh: ALL CHECKS PASSED.

🤖 Generated with Claude Code

…ges and 127.0.0.1 / ::1 only, not on every address of lo (Closes #178)

An interface= line makes dnsmasq add all of lo, and bind-dynamic opens a UDP and a TCP socket per address on it.
Hundreds of /128 source addresses on lo (ss-nodes, doubled while the ISP's prefix changes) used up the 1024
descriptors of all three instances: no DNS, `mr proxy check` failing, the migration that would drop the old addresses
never finishing. They now render `except-interface=lo` + `listen-address=127.0.0.1` + `listen-address=::1` and keep
bind-dynamic for the bridges.

Tests: TestDnsmasqListensOnBridgesAndLoopbackOnly, TestDNSHomeDnsmasqUnchanged (new lines), ci.d/dns.sh and
ci.d/proxy.sh (1000 extra /128 on lo, < 100 descriptors), lab scenario 16-dnsmasq-listen-scope.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Cd1s
Cd1s merged commit 02e892e into main Oct 25, 2026
2 checks passed
@Cd1s
Cd1s deleted the fix/dnsmasq-listen-scope branch October 25, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dns: dnsmasq listens on every address of lo and runs out of file descriptors (DNS and mr proxy check down)

1 participant