systemd-resolved error while reading 'ReadEtcHosts' config option

Asked by Thorsten on 2021-03-26

[~] # cat /etc/systemd/resolved.conf
[Resolve]
DNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888
Domains=
DNSStubListener=yes
ReadEtcHosts=yes

if my configs looks like this (above) I get the following error message at startup

systemd-resolved[21573]: /etc/systemd/resolved.conf:5: Unknown lvalue 'ReadEtcHosts' in section 'Resolve'

my systemd-version is the following

systemd-resolve --version
systemd 237

[~] # lsb_release -rd
Description: Ubuntu 18.04.5 LTS
Release: 18.04

[~] # apt-cache policy systemd
systemd:
  Installed: 237-3ubuntu10.45
  Candidate: 237-3ubuntu10.45
  Version table:
 *** 237-3ubuntu10.45 500

All updates of Ubuntu installed.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu systemd Edit question
Assignee:
No assignee Edit question
Last query:
2021-03-26
Last reply:
2021-04-05
Thorsten (thomic) said : #1

I guess this config option is not available in 18.04. can be closed.

Manfred Hampl (m-hampl) said : #2

From the NEWS.gz file

...
 CHANGES WITH 240:
...
        * systemd-resolved's configuration file resolved.conf gained a new
          option ReadEtcHosts= which may be used to turn off processing and
          honoring /etc/hosts entries.
...

So this option has been added only in version 240 (in disco and later) and is not available in version 237 in bionic.

Teodor Knapik (zolya) said : #3

I am facing a similar problem. Although I did not find an error message like Thorsten, I am noticing that

          ReadEtcHosts=yes

is set in /etc/systemd/resolved.conf and is ignored by systemd-resolved whereas it is clearly specifed in resolved.conf(5) that

       « If "yes" (the default), the DNS stub
           resolver will read /etc/hosts, and try to
           resolve hosts or address by using the entries
          in the file before sending query to DNS servers.»

Any comment on how to obtain this behaviour will be welcome.

Back to original post, I suggest Thorsten try to comment #ReadEtcHosts=yes in /etc/systemd/resolved.conf to avoid the error.

Concerning Manfred Hampl's reply, if the option has been added in version 240 of systemd-resolved, perhaps it has not been done properly ? Indeed my version is

    spectrum% apt-cache policy systemd
    systemd:
      Installed : 245.4-4ubuntu3.4
      Candidate : 245.4-4ubuntu3.5
     (... some other suff ...)

running on Ubuntu 20.04.2 LTS.

I would like to add to this discussion the following question:

   How to force systemd-resolved to resolve names from /etc/hosts before querying DNS servers ?
   If this behaviour cannot be obtained with a stable version of systemd-resolved running on Ubuntu 20.04.2 LTS, can it be with an alternative DNS stub resolver ?

Manfred Hampl (m-hampl) said : #4

@Theodor Knapik:

1. You better create a new question document for your problem

2. What is the output of the command
grep -i ReadEtcHosts /etc/systemd/resolved.conf /etc/systemd/resolved.conf.d/*.conf /usr/lib/systemd/resolved.conf.d/*.conf /usr/local/lib/systemd/resolved.conf.d/*.conf

Can you help with this problem?

Provide an answer of your own, or ask Thorsten for more information if necessary.

To post a message you must log in.