Skip to content

resolved assumes that /etc/hosts entry for one RR type means it doesn't ask DNS for another #4801

@martinpitt

Description

@martinpitt

Submission type

  • Bug report
  • Request for enhancement (RFE)

systemd version the issue has been seen with

232, master

Used distribution

Ubuntu 17.04

I got a downstream report about resolved's handling of /etc/hosts: If that contains e. g. an IPv4 address for a domain, then resolved does not query DNS for a corresponding IPv6 address any more. glibc on the other hand does that (i. e. the dns entry in nsswitch.conf).

Ordinarily systemd-resolve gets both v4 and v6 on an IPv6-enabled system:

$ ping -4 -c1 heise.de
PING heise.de (193.99.144.80) 56(84) bytes of data.
$ $ ping -6 -c1 heise.de
PING heise.de(redirector.heise.de (2a02:2e0:3fe:1001:302::)) 56 data bytes

But after adding 1.2.3.4 heise.de to /etc/hosts, IPv6 resolution is broken:

$ ping -4 -c1 heise.de
PING heise.de (1.2.3.4) 56(84) bytes of data.
# ^ correct, from /etc/hosts
$ ping -6 -c1 heise.de 
ping: heise.de: Name or service not known

Same with calling systemd-resolve heise.de, it now only shows an IPv4 address. This works with plain glibc "dns", it still contacts the DNS server for an IPv6 address.

This is done in https://github.com/systemd/systemd/blob/master/src/resolve/resolved-dns-query.c#L671 : If dns_query_try_etc_hosts() succeeds, it immediately declares the query as finished.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions