How to change the order of network card detection in Linux
In Category Linux
There are multiple issues you would notice when you have more than one Ethernet card (NIC) in your system. The NICs may not get detected in the order you want it to be. The on-board Ethernet port may get detected as “eth2″ while you want it to be detected as “eth0″.
Another problem is when you already have 3 Ethernet cards on your system and removed one them (more specifically the one which used to be detected as “eth1″). In such case, you system shows two Ethernet interfaces “eth0″ and “eth2″ while you might like it to be “eth0″ and “eth1″ as there are only two Ethernet interface available in the system.
Another problem is when you have replaced an old 100Mbps NIC with a new 1Gig NIC. Now the system attempts to apply the configuration (including hardware MAC address) to the new 1Gig NIC. One solution to this problem is to do the card replacement in two steps. First remove the old NIC and boot the system once to remove the old NIC from the hardware list using ‘Network Device Control’ or when kudzu prompts for it. The shut down the system and insert the new 1Gig NIC and boot the system again to add the new hardware.
In all these cases, especially in modern Linux distributions like Fedora, you should find the hardware detection rules defined by “udev”. There is a file “/etc/udev/rules.d/70-persistent-net.rules” which contains the list of interfaces and their names (eth0, eth1 etc). You can edit this file to change the name (eth0, eth1 etc) with which a card should be detected. Look at the following sample file.
[root@techpulp ~]# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
ATTR{address}=="00:07:e9:23:d7:c3", ATTR{type}=="1", KERNEL=="eth*",
NAME="eth0"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
ATTR{address}=="00:07:e9:23:d7:f4", ATTR{type}=="1", KERNEL=="eth*",
NAME="eth1"
# Intel Corporation 82562ET/EZ/GT/GZ - PRO/100 VE (LOM) Ethernet Controller
# (rule written by anaconda)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
ATTR{address}=="00:83:36:a5:3d:81", ATTR{type}=="1", KERNEL=="eth*",
NAME="eth2"
[root@techpulp ~]#
In the above example, the system has one on-board 100Mbps NIC and two 1Gig NICs connected using PCI. You can identify them using the hardware address as well. You can edit this file and modify the “NAME” field to change the order.
Recent Comments