AdGuardHome icon indicating copy to clipboard operation
AdGuardHome copied to clipboard

Private rDNS auto-discovery picks systemd-resolved's stub 127.0.0.53 from resolv.conf and loops back into AdGuard Home

Open wstock opened this issue 1 month ago • 1 comments

Prerequisites

Platform (OS and CPU architecture)

Linux, AMD64 (aka x86_64)

Installation

Docker

Setup

On one machine

AdGuard Home version

v0.107.79

Action

Host runs systemd-resolved; /etc/resolv.conf is nameserver 127.0.0.53 and resolved forwards to AdGuard Home (network_mode: host, bind_hosts: [0.0.0.0]). use_private_ptr_resolvers: true, local_ptr_upstreams: [] (the default, i.e. auto-discover from the system resolvers).

Minimal reproduction, no network needed:

printf 'nameserver 127.0.0.53\n' > resolv.conf
docker run -d --name agh --network none -v $PWD/resolv.conf:/etc/resolv.conf:ro adguard/adguardhome:latest   # config: bind_hosts [0.0.0.0], use_private_ptr_resolvers true, local_ptr_upstreams [], log verbose
docker exec agh nslookup -type=ptr 124.0.168.192.in-addr.arpa 127.0.0.1
docker logs agh 2>&1 | grep -E 'filtering out addresses|private-use upstreams|addr=127.0.0.53'

Expected result

127.0.0.53 is the host's own stub resolver, which forwards to AdGuard Home, so it should never be picked as a private rDNS upstream (the same reason Docker's 127.0.0.11 is excluded, #3064). Either skip loopback stub addresses during auto-discovery, or leave the private upstream list empty and log a warning.

Actual result

dnsforward: filtering out addresses addresses="[127.0.0.1 ::1]" ports=&{m:map[53:{}]}
dnsforward: private-use upstreams addrs=[127.0.0.53:53]
dnsproxy: sending request upstream_type=local addr=127.0.0.53:53 proto=udp qtype=PTR qname=124.0.168.192.in-addr.arpa.
dnsproxy: handling new packet raddr=127.0.0.1:43491 laddr=127.0.0.53 proto=udp

On the real host (resolved in between) the loop is silent: every private PTR query returns an empty NOERROR and the only trace is a handful of 2 s i/o timeout lines against upstream=127.0.0.53:53 per day. It ran unnoticed for months; local_ptr_upstreams: [192.168.0.1] fixes it.

Additional information and/or screenshots

Cause: newPrivateConfig (internal/dnsforward/upstreams.go) takes sysResolvers.Addrs() and removes only ourAddrsSet() (internal/dnsforward/config.go), which for an unspecified bind host is the set of interface addresses, so 127.0.0.1 is dropped but the 127.0.0.53 alias (not an interface address, reachable only via the 127/8 loopback route) survives. golibs netutil/sysresolv validateAddress (linux) excludes only 127.0.0.11. #6693 asks for general loop protection; this is the narrower case where the existing self-address filter misses a loopback stub. A cheap fix is to skip any system resolver whose address is loopback (netip.Addr.IsLoopback()) when the server listens on an unspecified or loopback address.

This report was prepared with AI assistance and verified on a real deployment and the container reproduction above.

wstock avatar Oct 29 '26 10:10 wstock

Thank you for letting us know. The information has been forwarded to the dev team.

sofvaskina avatar Oct 29 '26 13:10 sofvaskina