DNS troubles when connecting to lan/wlan using networkmanager

Since i couple of days i have been having this problem where upon connecting to a network (wlan, lan) i get an ip adress, but dns seems not to be working. It seems to happen randomly, sometimes i connect and everything is fine. Other times, i have to manually run dhcpcd on my network interface to make dns work. (When the dns is not working i can still ping for example 8.8.8.8 successfully).

Im not really sure where to look for problems here. Do i have to put anything specific into my /etc/hosts file?

No.
The DNS server(s) are specified in /etc/resolv.conf.

Maybe that file is corrupted/empty?
But then it should not work every time.

Anyway, try to run “sudo netconfig update -f”, this should recreate resolv.conf from scratch according to your settings. Maybe that helps?

You do have DHCP activated in NetworkManager’s settings I hope?

You do have DHCP activated in NetworkManager’s settings I hope?

I really havent touched NetworkManager’s settings at all. Well, except when adding connection profiles for wlans/lans. Didnt find anything relevant to dhcp settings under /etc/NetworkManager/

I know i can make NetworkManager use a specific client (dhcpcd and dhclient is what is available on my system) through putting dhcp=dhcpcd in /etc/NetworkManager/NetworkManager.conf. But i assume thats not what you mean?

Edit: And i checked the /etc/resolv.conf file, the settings are the same pre/post running netconfig update -f as root!

(thanks for the quick answer btw)

No, I mean the connection settings in your Desktop Environment’s Network Manager applet.
You can choose between “Automatic (DHCP)”, “Automatic (DHCP) - only addresses”, “Manual”, and so on.

This would be saved in /etc/NetworkManager/system-connections/, as “method=xxx”.

But “Automatic (DHCP)” should be the default.

Maybe have a look at the output of “sudo systemctl status -l NetworkManager” the next time it fails.

Right, i get it. Its on auto atm. From what i understand that is a per profile setting? But anyway, since i actually get an ip adress i would assume the problem is somewhere else.

Ok, after some more testing. I guess the pid file for the old dhcpcd connection is not removed properly after being connected to one wlan then connecting to another. (I assume this is how it works, the old pid file has to be removed, a new one is created upon running a dhcp client again).

Anyway here is the output of your suggested status check:

# systemctl status -l NetworkManager
NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled)
   Active: active (running) since Wed 2014-07-09 16:26:13 CEST; 25s ago
 Main PID: 7511 (NetworkManager)
   CGroup: /system.slice/NetworkManager.service
           ├─7511 /usr/sbin/NetworkManager --no-daemon
           └─7687 /sbin/dhclient -d -sf /usr/lib/nm-dhcp-client.action -pf /var/run/dhclient-wlp3s0.pid -lf /var/lib/NetworkManager/dhclient-76792539-e598-4172-9701-55d407dc57cb-wlp3s0.lease -cf /var/lib/NetworkManager/dhclient-wlp3s0.conf wlp3s0


Jul 09 16:26:21 fesk.site NetworkManager[7511]: <info> Activation (wlp3s0) Stage 5 of 5 (IPv4 Commit) complete.
Jul 09 16:26:21 fesk.site NetworkManager[7511]: <info> (wlp3s0): device state change: secondaries -> activated (reason 'none') [90 100 0]
Jul 09 16:26:21 fesk.site NetworkManager[7511]: <info> NetworkManager state is now CONNECTED_GLOBAL
Jul 09 16:26:21 fesk.site NetworkManager[7511]: <info> Policy set 'ansjoser' (wlp3s0) as default for IPv4 routing and DNS.
Jul 09 16:26:21 fesk.site NetworkManager[7511]: <info> Activation (wlp3s0) successful, device activated.
Jul 09 16:26:22 fesk.site dns-resolver[7748]: You can find my version in /etc/resolv.conf.netconfig
Jul 09 16:26:22 fesk.site NetworkManager[7511]: dns-resolver: ATTENTION: You have modified /etc/resolv.conf. Leaving it untouched...
Jul 09 16:26:22 fesk.site NetworkManager[7511]: dns-resolver: You can find my version in /etc/resolv.conf.netconfig
Jul 09 16:26:22 fesk.site NetworkManager[7511]: ATTENTION: You have modified /etc/resolv.conf.  Leaving it untouched...
Jul 09 16:26:22 fesk.site NetworkManager[7511]: You can find my version in /etc/resolv.conf.netconfig ...

Here is the relevant output of /etc/resolv.conf.netconfig:

nameserver 192.168.1.1

And here is the output of the current /etc/resolv.conf (the one networkmanager is assuming is modified)

# Generated by dhcpcd for interface wlp3s0
nameserver 192.168.43.1



Uhm. For some reason i cant edit my last post. 192.168.43.1 is the gateway for the wlan my phone uses when activating wifi hotspot. Had to do it for testing. 192.168.1.1 is the proper router i use at home. So when connecting to the phone then my home router this stuff happens.

It is per connection.

But anyway, since i actually get an ip adress i would assume the problem is somewhere else.

You could have set it to “Auto (DHCP) - only addresses”, you would get an IP address then, but no other settings like DNS-Server.
But of course the problem would occur on every boot then if something would have been wrong there.

Ok, after some more testing. I guess the pid file for the old dhcpcd connection is not removed properly after being connected to one wlan then connecting to another. (I assume this is how it works, the old pid file has to be removed, a new one is created upon running a dhcp client again).

NetworkManager doesn’t use dhcpcd by default. It uses dhclient.

And here is the output of the current /etc/resolv.conf (the one networkmanager is assuming is modified)

# Generated by dhcpcd for interface wlp3s0
nameserver 192.168.43.1

As you can see that one is created by dhcpcd.
netconfig doesn’t overwrite/change it because it looks different from what it would create, which looks like this:

### /etc/resolv.conf file autogenerated by netconfig!
#
# Before you change this file manually, consider to define the
# static DNS configuration using the following variables in the
# /etc/sysconfig/network/config file:
#     NETCONFIG_DNS_STATIC_SEARCHLIST
#     NETCONFIG_DNS_STATIC_SERVERS
#     NETCONFIG_DNS_FORWARDER
# or disable DNS configuration updates via netconfig by setting:
#     NETCONFIG_DNS_POLICY=''
#
# See also the netconfig(8) manual page and other documentation.
#
# Note: Manual change of this file disables netconfig too, but
# may get lost when this file contains comments or empty lines
# only, the netconfig settings are same with settings in this
# file and in case of a "netconfig update -f" call.
#
### Please remove (at least) this line when you modify the file!
search home
nameserver 10.0.0.138


So run “sudo /sbin/netconfig update -f” as I already wrote to force netconfig to recreate the file.

You can only edit a post for 10 minutes after creating it.

192.168.43.1 is the gateway for the wlan my phone uses when activating wifi hotspot. Had to do it for testing. 192.168.1.1 is the proper router i use at home. So when connecting to the phone then my home router this stuff happens.

So this is reproduceable?
Well, try that netconfig command, and then try to reproduce it.

And do not run dhcpcd manually.

Do I understand you right, that you used your phone as “router”?
Does this happen everytime after you connected to your phone? Or maybe only if both the connection to the phone and the connection to the router are active?

On 2014-07-09 17:16, wolfi323 wrote:

> Do I understand you right, that you used your phone as “router”?
> Does this happen everytime after you connected to your phone? Or maybe
> only if both the connection to the phone and the connection to the
> router are active?

I experiment a similar situation with my laptop, but mine works.

I connect via wifi to my router at home, or to my android mobile phone,
acting as access point, and internet router. They are different
networks, gateway, dns - everything changes, and network manager handles
it well, writing the appropriate changes.

Well, there is one change it does not do: edit the hosts file with the
appropriate new address for the machine name.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)