You are not logged in.

#1 2022-05-10 09:13:24

Benjamin13
Member
Registered: 2016-11-03
Posts: 13

NetworkManager keeps previous DNS when switching networks

I've been having an issue since a few weeks with my DNS settings.

I first noticed some very long name resolutions so I investigated a bit and found that in /etc/resolv.conf I end up with a mix of DNS addresses, one from my home router, and two from my company DNS server.

Let's say I start my computer when I'm home. In that case I have the following resolv.conf:

# Generated by NetworkManager
search home
nameserver 192.168.1.1

But then I take my laptop to work, connect to the wired and/or wifi networks and get:

# Generated by NetworkManager
search home company.com
nameserver 192.168.1.1
nameserver 193.64.105.163
nameserver 193.64.105.150

Which leads to very slow name resolutions as the DNS client probably hangs on the first address until it times out and then try the second, correct, one and get its result.

I can fix resolv.conf either manually or by restarting the NetworkManager service but it is a bit annoying so I would like to know if there is a way so that NetworkManager drops the a connection's DNS settings when that connection goes down.

I have no manual DNS settings in the connections I use, everything is on automatic.

Offline

#2 2022-05-10 12:27:33

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

Re: NetworkManager keeps previous DNS when switching networks

You are not alone: https://bbs.archlinux.org/viewtopic.php?id=275236

Is the content of the file

/run/NetworkManager/resolv.conf

identical?

Last edited by -thc (2022-05-10 12:28:40)

Offline

#3 2022-05-10 12:41:33

seth
Member
Registered: 2012-09-03
Posts: 33,585

Re: NetworkManager keeps previous DNS when switching networks

Offline

#4 2022-05-11 09:52:14

Benjamin13
Member
Registered: 2016-11-03
Posts: 13

Re: NetworkManager keeps previous DNS when switching networks

-thc wrote:

You are not alone: https://bbs.archlinux.org/viewtopic.php?id=275236

Is the content of the file

/run/NetworkManager/resolv.conf

identical?

Yes but I'll have to switch from my work to home network to see if it's still the case after that

Offline

#5 2022-05-11 09:52:47

Benjamin13
Member
Registered: 2016-11-03
Posts: 13

Re: NetworkManager keeps previous DNS when switching networks

Nice the see the issue being tracked. I guess I'll have to be patient

Offline

#6 2022-05-11 19:44:34

Benjamin13
Member
Registered: 2016-11-03
Posts: 13

Re: NetworkManager keeps previous DNS when switching networks

I confirm that

/etc/resolv.conf

and

/run/NetworkManager/resolv.conf

are identical, and still broken, after switching networks

Offline

#7 2022-05-11 19:47:41

progandy
Member
Registered: 2012-05-17
Posts: 5,048

Re: NetworkManager keeps previous DNS when switching networks

Does networkmanager do the right thing when you set it up to use systemd-resolved?

Last edited by progandy (2022-05-11 19:48:33)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#8 2022-05-12 08:39:12

Benjamin13
Member
Registered: 2016-11-03
Posts: 13

Re: NetworkManager keeps previous DNS when switching networks

I just enabled it but I have to wait to get back home to see if it solved the problem.

Offline

#9 2022-05-13 09:20:16

Benjamin13
Member
Registered: 2016-11-03
Posts: 13

Re: NetworkManager keeps previous DNS when switching networks

It didn't change anything, I still get the DNS mixed up

Offline

#10 2022-05-13 12:12:18

seth
Member
Registered: 2012-09-03
Posts: 33,585

Re: NetworkManager keeps previous DNS when switching networks

https://bbs.archlinux.org/viewtopic.php … 9#p2029019
You could try to build NM w/ that commit reverted and see whether that helps and post your findings at the bug linked earlier.

Offline

Board footer

Powered by FluxBB