You are not logged in.

#1 2022-03-30 15:31:27

larsko
Member
Registered: 2019-12-21
Posts: 6

/etc/resolv.conf contains old entries from previous DHCP connection

I'm having issues with /etc/resolv.conf being generated incorrectly by NetworkManager. It seems to keep track of all DNS servers it has ever received and add all of them to /etc/resolv.conf instead of just the DNS servers for the current connection. This started happening a few weeks ago (presumably after a NetworkManager update), but unfortunately I don't remember when exactly. The generated file looks like this:

# Generated by NetworkManager
nameserver a.a.a.a
nameserver b.b.b.b
nameserver x.x.x.x
# NOTE: the libc resolver may not support more than 3 nameservers.
# The nameservers listed below may not be recognized.
nameserver y.y.y.y

where a.a.a.a and b.b.b.b are the nameservers from the first DHCP connection connected to after starting NetworkManager, and x.x.x.x and y.y.y.y are the nameservers from the second connection (the "saved" old nameservers go away when NetworkManager is restarted). I've tried changing rc-method for NetworkManager from file to resolvconf, with the same result (and then resolvconf -l shows the old nameservers as well). However, checking the interface itself gives the right nameservers, i.e.  nmcli device show <iface> shows the correct DNS servers (and only the correct DNS servers).

Here are the contents of a few more files that may be relevant:

/etc/nsswitch.conf:

# Name Service Switch configuration file.
# See nsswitch.conf(5) for details.

passwd: files systemd
group: files [SUCCESS=merge] systemd
shadow: files systemd
gshadow: files systemd

publickey: files

hosts: mymachines resolve [!UNAVAIL=return] files myhostname dns
networks: files

protocols: files
services: files
ethers: files
rpc: files

netgroup: files

/etc/NetworkManager/conf.d/dns.conf:

[main]
rc-manager=file

/etc/NetworkManager/NetworkManager.conf is empty.

As I said above, I didn't change any configuration files or connection configurations, so I suspect that a NetworkManager update is to blame. I checked the recent version history, but didn't see anything obvious. Currently running NetworkManager version 1.36.2-1.

Any help appreciated! Thanks!

Offline

#2 2022-03-30 18:16:06

-thc
Member
Registered: 2017-03-15
Posts: 204

Re: /etc/resolv.conf contains old entries from previous DHCP connection

Is "/etc/resolv.conf" a file or a symbolic link?

I didn't change any NetworkManagers files either and mine looks like this:

etc/NetworkManager/conf.d/dns.conf

[main]
dns=default
systemd-resolved=false

To verify that NetworkManager alone is responsible, you can try this with an emptied resolv.conf:

/etc/NetworkManager/conf.d/dns.conf

[main]
dns=none
systemd-resolved=false

Offline

#3 2022-03-30 18:25:14

larsko
Member
Registered: 2019-12-21
Posts: 6

Re: /etc/resolv.conf contains old entries from previous DHCP connection

Thanks, /etc/resolv.conf is a file. The systemd-resolved service is disabled. NetworkManager alone is responsible for changing /etc/resolv.conf (verified by logging access to /etc/resolv.conf using fatrace).

Offline

#4 2022-03-30 20:03:30

-thc
Member
Registered: 2017-03-15
Posts: 204

Re: /etc/resolv.conf contains old entries from previous DHCP connection

Then this

[main]
rc-manager=file

is somewhat redundant.

Can you clarify the nature of the "second connection" which causes the additional entries?

Offline

#5 2022-03-30 20:16:23

larsko
Member
Registered: 2019-12-21
Posts: 6

Re: /etc/resolv.conf contains old entries from previous DHCP connection

Yes, I put that there to be really sure.

There's nothing specific about the second connection, I just happen to switch between two (home and work). Both are wired connections, but the same happens for wireless connections. It looks like NetworkManager maintains a record of all DNS servers it has seen for any connections, and puts all of these into /etc/resolv.conf in the order in which they were seen. The order depends only on the order in which I connect, i.e. the "first" connection can be the "second" connection and vice versa.

Offline

#6 2022-03-30 21:07:40

seth
Member
Registered: 2012-09-03
Posts: 29,931

Re: /etc/resolv.conf contains old entries from previous DHCP connection

Offline

Board footer

Powered by FluxBB