Several months ago a new entry ‘eth0’ began appearing under ‘Available connections‘ in the KDE plasma-nm widget (the KDE GUI front-end to NetworkManager) in my Gentoo Linux installation. However, there was already an automatically-created entry ‘Wired connection 1’ for the wired interface. In the plasma-nm GUI I could see that both entries were for the same interface (eth0) and MAC address. My laptop could access the Internet via the connection ‘Wired connection 1’ as usual, but not via the new connection ‘eth0’. And if I deleted ‘eth0’ in the plasma-nm GUI, ‘Wired connection 1’ could not access the Internet until I recreated ‘eth0’ manually.
Apart from the fact that two entries for the same interface is unnecessary, it was annoying because sometimes ‘eth0’ automatically became the active connection instead of ‘Wired connection 1’, despite the fact that only ‘Wired connection 1’ had ‘Automatically connect to this network when it is available’ ticked in the plasma-nm GUI. When this happened, the network icon on the Panel showed an active connection but in fact the laptop could not connect to the Internet. However, the connection did work as expected on the occasions when ‘Wired connection 1’ automatically became the active connection or if I switched manually to ‘Wired connection 1’ via the plasma-nm GUI.
Even more strangely, if I happened to be using WiFi when no Ethernet cable was connected, very occasionally the network icon on the Panel would change from a wireless icon to a wired icon and connection to the Internet would be lost. I would then have to re-select the wireless network in order to reconnect to the Internet.
As my laptop has only one Ethernet port, and as there was previously no ‘eth0’ entry under ‘Available connections‘, initially I thought that the new entry occurred because I had recently installed a new version of udev. I have the parameter net.ifnames=0
in the kernel boot line to stop udev/eudev using the so-called Predictable Network Interface Names, and I have the following udev/eudev rules files relating to networking:
# ls -la /etc/udev/rules.d/*net*
lrwxrwxrwx 1 root root 9 Nov 30 15:25 80-net-setup-link.rules -> /dev/null
# ls -la /lib64/udev/rules.d/*net*
-rw-r--r-- 1 root root 452 Nov 7 09:57 /lib64/udev/rules.d/75-net-description.rules
-rw-r--r-- 1 root root 1734 Jan 28 18:29 /lib64/udev/rules.d/77-mm-huawei-net-port-types.rules
-rw-r--r-- 1 root root 491 Nov 7 09:57 /lib64/udev/rules.d/80-net-name-slot.rules
-rw-r--r-- 1 root root 280 Jan 24 00:41 /lib64/udev/rules.d/90-network.rules
Perhaps udev (well, eudev, as I switched to using eudev after the problem started) did have something to do with the new entry, but I began to suspect that NetworkManager was the culprit. I think the problem first occurred after installing NetworkManager 0.9.10.0 last October, but it remained after I installed NetworkManager 1.0.0, until today when I made the various changes described further on.
I had merged NetworkManager 1.0.0 and preceding versions since 0.9.8.8 with USE flags -dhclient
and dhcpcd
, i.e. NetworkManager in my installation uses the DHCP client dhcpcd instead of dhclient. (I used to merge NetworkManager to use dhclient but found it did not work with 0.9.8.8 and later versions of NetworkManager.)
The relevant network services running in my installation are as follows, and nothing looks incorrect to me:
# rc-update show | grep -i net
NetworkManager | default
local | default nonetwork
net.lo | boot
netmount | default
# rc-status | grep -i net
NetworkManager [ started ]
netmount [ started ]
# rc-update show | grep dh
# rc-status | grep dh
# rc-update -v show | grep supplicant
wpa_supplicant |
# rc-status | grep supplicant
#
NetworkManager itself launches the DHCP client, so the installation should not be configured to launch a DHCP client. Indeed the output above shows that no DHCP client service is configured to run independently of NetworkManager, and I also double-checked that multiple instances of a DHCP client are not running (they’re not):
# ps -C NetworkManager
PID TTY TIME CMD
6481 ? 00:00:22 NetworkManager
# ps -C dhcpcd
PID TTY TIME CMD
10378 ? 00:00:00 dhcpcd
# ps -C dhclient
PID TTY TIME CMD
#
As far as WiFi is concerned, NetworkManager itself launches wpa_supplicant, so the installation should not be configured to launch wpa_supplicant. Indeed the output from rc-update
and rc-status
above shows that no wpa_supplicant service is configured to run independently of NetworkManager, and I also double-checked that multiple instances of wpa_supplicant are not running (they’re not):
# ps -C wpa_supplicant
PID TTY TIME CMD
6491 ? 00:00:00 wpa_supplicant
#
So, as far as I could tell, there was nothing wrong with the non-NetworkManager side of my installation.
I thought the problem might be due to the settings in the file /etc/NetworkManager/NetworkManager.conf
, which contained the following:
[main]
plugins=keyfile
dhcp=dhcpcd
[ifnet]
managed=true
auto_refresh=false
[keyfile]
hostname=meshedgedx
I studied the manual pages for NetworkManager.conf
:
# man NetworkManager.conf
If I understand correctly, the ifnet plug-in is Gentoo-specific (see References 3, 4 and 5 further on). The entries under [ifnet]
in my NetworkManager.conf
file were redundant in any case because the ifnet plug-in was not included in the plugins
list under [main]
, so I deleted the entire [ifnet]
section. There is no mention of the ifnet plug-in on the NetworkManager.conf
manual page or in the Gentoo Linux Wiki article on NetworkManager, and a cursory look in the Gentoo ebuild for NetworkManager 1.0.0 clearly indicates the ifnet plug-in is broken. See, for example, the following comment in the ebuild:
# ifnet plugin always disabled until someone volunteers to actively
# maintain and fix it
and the following warning messages in the ebuild if the user has included ifnet in plugin=
<plugin list> in NetworkManager.conf
:
ewarn "Ifnet plugin is now disabled because of it being unattended"
ewarn "and unmaintained for a long time, leading to some unfixed bugs"
ewarn "and new problems appearing. We will now use upstream 'keyfile'"
ewarn "plugin."
ewarn "Because of this, you will likely need to reconfigure some of"
ewarn "your networks. To do this you can rely on Gnome control center,"
ewarn "nm-connection-editor or nmtui tools for example once updated"
ewarn "NetworkManager version is installed."
ewarn "You seem to use 'ifnet' plugin in ${EROOT}etc/NetworkManager/NetworkManager.conf"
ewarn "Since it won't be used, you will need to stop setting ifnet plugin there."
I modified NetworkManager.conf
to contain the following:
[main]
plugins=keyfile
dhcp=dhcpcd
no-auto-default=eth0
[keyfile]
hostname=meshedgedx
Note that the ifnet plug-in was not specified in the plugins
list in the [main]
section of my previous NetworkManager.conf
so it was not the cause of my problem, but I hoped that adding no-auto-default=eth0
to NetworkManager.conf
would solve the problem. I deleted the ‘Wired connection 1’ entry from the plasma-nm GUI, ticked ‘Automatically connect to this network when it is available’ for the ‘eth0’ entry and made sure that option was not ticked for any of the other entries under ‘Available connections‘, then rebooted. There was no longer an entry ‘Wired connection 1’ in the plasma-nm widget GUI, just an entry for ‘eth0’, and the installation connected automatically to the wired network and I could access the Internet, but did not reconnect to the wired network if I removed and reinserted the Ethernet cable when also connected to a wireless network. So I was not home and dry yet.
I have read on various Web sites that NetworkManager prefers wired connections over wireless connections. I assume this is because NetworkManager sets a higher metric for the wired connection.
I am on a work trip at the moment and cannot use a dynamic wired connection, only a static wired connection, but I can see that NetworkManager 1.0.0 does set a higher-priority metric for wired connections:
# # Now with both dynamic wireless and static wired:
# ip route show
default via 10.90.21.1 dev eth0 proto static metric 100
default via 10.96.0.1 dev wlan0 proto static metric 600
10.90.21.0/24 dev eth0 proto kernel scope link src 10.90.21.112 metric 100
10.96.0.0/16 dev wlan0 proto kernel scope link src 10.96.87.86
10.96.0.0/16 dev wlan0 proto kernel scope link src 10.96.87.86 metric 303
127.0.0.0/8 dev lo scope host
127.0.0.0/8 via 127.0.0.1 dev lo
192.0.2.1 via 10.96.0.1 dev wlan0 proto dhcp metric 600
#
10.90.21.1 is the IP address of the gateway for the wired connection, and 10.90.21.112 is the IP address of my laptop’s wired interface. The smaller the metric value, the higher the routing priority. Notice that the metric for the eth0 interface is 100 whereas the metric for the wlan0 interface is 600, so it does appear that NetworkManager favours a wired connection over a wireless connection when both are active.
After doing all the above, I came across Debian bug report no. 755202: network-manager: keeps creating and using new connection “eth0” that does not work which appears to be exactly what I was experiencing. Various people posted solutions that worked in their particular circumstances, so I am none the wiser. Gentoo user Keivan Moradi posted message no. 79 on that bug report, about a warning message he found in the NetworkManager log file regarding a file /etc/NetworkManager/system-connections/.keep_net-misc_networkmanager-0
, and he then deleted the latter file. I found the same message in /var/log/messages
:
# grep networkmanager /var/log/messages
Feb 9 04:10:05 localhost NetworkManager[10355]: <warn> error in connection /etc/NetworkManager/system-connections/.keep_net-misc_networkmanager-0: invalid connection: connection.type: property is missing
Feb 11 15:53:05 localhost NetworkManager[13143]: <warn> error in connection /etc/NetworkManager/system-connections/.keep_net-misc_networkmanager-0: invalid connection: connection.type: property is missing
The file /etc/NetworkManager/system-connections/.keep_net-misc_networkmanager-0
also existed in my installation, so I also deleted it. It was a zero-length file and I do not know if it had anything to do with my problem:
# ls -la /etc/NetworkManager/system-connections/.keep_net-misc_networkmanager-0
-rw------- 1 root root 0 Jan 20 00:09 /etc/NetworkManager/system-connections/.keep_net-misc_networkmanager-0
# rm /etc/NetworkManager/system-connections/.keep_net-misc_networkmanager-0
#
Anyway, the file /etc/NetworkManager/system-connections/.keep_net-misc_networkmanager-0
has not reappeared since I deleted it.
Keivan Moradi had ‘id=Wired
‘ under [connection]
in the file /etc/NetworkManager/system-connections/eth0
, and he decided to change the name of the file from ‘eth0
‘ to ‘Wired
‘. However, in my case the file name and the id in the file /etc/NetworkManager/system-connections/eth0
are both ‘eth0
‘:
# cat /etc/NetworkManager/system-connections/eth0
[ethernet]
mac-address=70:5A:B6:3E:C1:8A
mac-address-blacklist=
[connection]
id=eth0
uuid=cb3d5786-f947-44b8-92f7-8471fc94c568
type=ethernet
permissions=
secondaries=
[ipv6]
method=ignore
dns-search=
[ipv4]
method=auto
dns-search=
I had already deleted and recreated the connection ‘eth0’ in the plasma-nm GUI by the time I checked the contents of the directory /etc/NetworkManager/system-connections/
so I do not know if the original file name and id were the same. I had also already deleted the connection ‘Wired connection 1’ in the plasma-nm GUI by the time I checked the contents of the directory; presumably files for connections ‘Wired connection 1’ and ‘eth0’ both existed in /etc/NetworkManager/system-connections/
before then. I do not know why the zero-length file .keep_net-misc_networkmanager-0
was created, but no further files have appeared in the directory since I deleted the connection ‘Wired connection 1’ and the file .keep_net-misc_networkmanager-0
.
Keivan Moradi was also previously using a buggy r8169 kernel module (Realtek Ethernet hardware) and switched to using the r8168 module, but I am using a Qualcomm Atheros AR8131 Gigabit Ethernet card and an Intel Corporation Ultimate N WiFi Link 5300 card, so that part of his problem cannot be a factor in my case.
Anyway, as I wrote earlier, I no longer have two connection entries for the wired interface, and NetworkManager no longer creates automatically a second connection entry for the wired interface. And now if I am already connected to a wireless network, NetworkManager connects/reconnects automatically to a wired network with the ‘Automatically connect’ option ticked. So it looks like my problem is completely solved, although I reserve judgement until I have been able to use the laptop in my home network (which has the same router for both wired and wireless connections, whereas the wired network and wireless network are separate networks in the office in which I am now working).
Conclusion
If you had the patience to read all the above, I am impressed! If you also understood it, I am doubly impressed!
To cut a long story short, if you are experiencing a similar problem to mine, I recommend you do the following:
- Check that your network driver is reliable. You can search the Web to see if other users have experienced problems with the same driver you are using.
- Make sure the contents of
NetworkManager.conf
are correct. Read the NetworkManager.conf
man page and the GNOME Wiki page on NetworkManager settings to find out what options are available.
- Delete all the files (i.e. including hidden files) in the directory
/etc/NetworkManager/system-connections/
and recreate your connections via either the NetworkManager GUI (e.g. plasma-nm in KDE or nm-applet in GNOME) or NetworkManager TUI (nmtui).
References
- man NetworkManager.conf
- Gentoo Linux Wiki – NetworkManager
- GNOME Wiki – NetworkManager SystemSettings – Configuration Plugins
- Gentoo NetworkManager Plugin
- Another Gentoo Dev – Ifnet updates for NetworkManager 0.9
UPDATE (March 10, 2015): Well, I was right to reserve judgement until I was able to use my laptop with my home network. I am now back at home and an Ethernet cable is plugged into my laptop’s RJ45 socket. Even with the changes I made, when I boot the laptop NetworkManager sometimes (but not always) has two connections named ‘eth0’, one of them the ‘Active connection’ (but not able to connect to the Internet) and the other an ‘Available connection’. In this situation the wired network icon on the Panel has a yellow question mark superimposed. If I delete the ‘eth0’ active connection and use the other ‘eth0’, the latter works as expected and I have no trouble connecting to the Internet. In Debian bug report no. 755202 (see the link further up) user Frederik Himpe added a comment on March 4, 2015 that he is also still experiencing this problem and “It looks like there is a race somewhere, causing the network interface to be brought up before Network Manager is started, and this prevents correct configuration by NM”. So the problem is still unresolved. Hmm … I wonder if udev does have something to do with it after all.
UPDATE (March 12, 2015): The problem persists. I disabled use of IPv6 in /etc/avahi/avahi-daemon.conf
to see if the Avahi daemon has something to do with the problem, but that made no difference. Later I also disabled use of IPv4 in /etc/avahi/avahi-daemon.conf
, but that made no difference either. So it looks like the Avahi daemon is not the culprit. Checking via the plasma-nm GUI I notice that the ‘rogue’ eth0 Active connection has IPv4 disabled and IPv6 Link-Local enabled. So why is NetworkManager creating a second eth0 connection just for IPv6 Link-Local? And why on Earth is NetworkManager creating any additional connection at all when NetworkManager.conf
contains no-auto-default=eth0
? Surely this must be a bug in NetworkManager 1.0.0?
UPDATE (March 17, 2015): I have been investigating the problem further: see my latest blog post for details.