With export-etc-hosts enabled, the recursor in bookworm only serves the
first line of /etc/hosts for a name. If a name is listed with an IPv4 and
an IPv6 address on two lines, only one of the two record types is
answered.
Steps to reproduce (Debian 12 based system, pdns-recursor 4.8.8-1+deb12u1,
export-etc-hosts=yes):
/etc/hosts:
192.0.2.77 plain.test
2001:db8::77 plain.test
rec_control reload-zones
dig +short @127.0.0.1 plain.test A -> 192.0.2.77
dig +short @127.0.0.1 plain.test AAAA -> (empty)
With the two lines in the opposite order only the AAAA record is
answered. In 4.8.8 makeNameToIPZone() in reczones-helpers.cc creates a
new zone for each line and addToDomainMap() refuses to replace an
existing one ("Will not overwrite already loaded zone").
Upstream fixed this in 4.9.0, PowerDNS pull request 12203, commit
a867410a2183e64d6abe212c5abcac7cf8a95b6b "Allow multiple records with
same name for etc/hosts processing" (15 lines added, 2 removed, one
file). With upstream 5.4.7 both records of the example are answered.
Debian 13 should not be affected, because the fix is in all releases
since 4.9.0, but I have not tested the trixie package.
The patch applies cleanly to the 4.8.8 source. I checked this with
"patch --dry-run" against the rec-4.8.8 tag and did not build or run a
patched package. A patch in DEP-3 format is attached.
I know that 4.x is end of life upstream, so a fix has to come from
Debian. Could this be considered for a bookworm point release? I noticed
it in VyOS (a Debian 12 based router distribution), where DHCP and static
host mappings for the same name use different address families and only
one of them resolves. I am happy to test a patched package.