problem resoving DNS

I’m having a problem that appears to occur at random. When I either disconnect from a VPN or just switch from one wifi connection to another, I will lose DNS resolution. The resolv.conf file gets updated with the correct nameservers, but I still won’t be able to resolve DNS until I run

netconfig -f update

. Then everything works fine. It’s only mildly annoying, and easily fixed when it occurs, but does anyone know what might be causing this? I cannot reliably reproduce the problem since it does not always happen when switching networks or using a VPN, but I have noticed that it occurs right after one of those two events.

I assume that you’re using NetworkManager? Do you also start and stop the VPN with NetworkManager?

Yes, I’m using network manager. I have a couple VPNs that I use. One is through NetExtender and the other I can connect to via either network manager or its own application. I’ve noticed this happened once when switching from one wifi network to another, and it happened again yesterday after disconnecting from NetExtender. I tried to reproduce the problem both times but was unable to do so. I haven’t noticed the problem when using the VPN through network manager (yet). I’ll try connecting to each VPN using network manager and their own apps and see if I can get it to happen again.

It makes sense that it could happen if using a third-party utility, since NM won’t know that the DNS needs updating again, and in any case if /etc/resolv.conf is modified by external means it won’t touch it.

I tried to reproduce the problem both times but was unable to do so. I haven’t noticed the problem when using the VPN through network manager (yet). I’ll try connecting to each VPN using network manager and their own apps and see if I can get it to happen again.

That is as I would expect as well, since NM is managing /etc/resolv.conf.

Could this perhaps be avoided by permanently using public namervers like OpenDNS? I do this on my laptop to avoid resolver problems when travelling.

On 07/16/2018 04:46 PM, z2 wrote:
>
> I’m having a problem that appears to occur at random. When I either
> disconnect from a VPN or just switch from one wifi connection to
> another, I will lose DNS resolution. The resolv.conf file gets updated
> with the correct nameservers, but I still won’t be able to resolve DNS
> until I run
> Code:
> --------------------
> netconfig -f update
> --------------------

One possibility is that the routing tables are not being properly
updated. Next time you have this problem run:

Code:


ip r


/Code:

before and after running you netconfig command and see if there are
differences.


Ken
linux since 1984
S.u.S.E./openSUSE since 1998

This issue resurfaced again after a few weeks. I ran the above code before and after running netconfig -f update. There is no difference.

output of ip r while connected to VPN:

default via 192.168.1.1 dev wlan0 proto dhcp metric 600 
192.0.2.1 dev ppp0 proto kernel scope link src 10.80.80.100 
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.2 metric 600 
192.168.1.1 dev wlan0 scope link 
192.168.13.0/24 via 10.80.80.100 dev ppp0 scope link 
192.199.226.117 via 192.168.1.1 dev wlan0

output of ip r after disconnecting and having no DNS resolution:

default via 192.168.1.1 dev wlan0 proto dhcp metric 20600 
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.2 metric 600

After running netconfig -f update the output of ip r does not change, but DNS resolution is restored.

No, that take won’t take care of routing tables. Whatever you use as the VPN client (activating/deactivating the VPN) should take care of cleaning up the routes if needed.

I did note that after disconnecting, the metric changed to 20600.

default via 192.168.1.1 dev wlan0 proto dhcp metric 20600  
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.2 metric 600

After this, VPN connections were extremely slow. Today, the metric is staying at 600 whether or not I’m connected to a VPN, and everything is fast.
Is there a way to manually change the metric only, or do I have to delete and recreate the route?

Delete and recreate the route as required.

As “Explorer Penguin” informed DNS lost problem appears to occur at random (with wlan and wired).

Next terminal command lines seems to repair problem (HW: Dell D620)

>sudo netconfig upgrade -f
>sudo killall NetworkManager
>sudo systemctl start NetworkManager

After commands wlan and wired connection has access to DNS and webpages are opened correctly.

Thanks for the information. Next time this problem shows up again, I will try this.