Changing Ethernet Device Names in EL7 and Fedora 15+: Difference between revisions
(→Steps) |
Revision as of 12:14, 7 October 2012
AN!Wiki :: How To :: Changing Ethernet Device Names in EL7 and Fedora 15+ |
Warning: The topic includes RHEL v7, which has not be released. It may well prove that the methods described here will not work with the final release of Red Hat Enterprise Linux version 7. Best guesses on how things will work inform this tutorial and may prove wrong. |
Warning: This is not finished and may well contain errors and omissions. Proceed with caution! Better yet, don't proceed at all. :) |
With Fedora 15, Fedora moved away from the traditional network device naming of ethX to a variety of names, depending on how the network card is physically connected to the machine. This is possible thanks to biosdevname which allows better tracking of hardware with the goal of making the names of devices more predictable. Given that it is predictable, there is good reason to leave the names as they are and adapt to the new naming system.
This tutorial will disable biosdevname entirely. This will not just revert the device names to ethX. It will allow the device names to be anything you like. This tutorial is not meant to advocate against these changes. However, there are cases ranging from simple familiarity to application compatibility that might make you want to use different network device names.
Steps
cp /etc/default/grub ~/grub.orig
vim /etc/default/grub
Append biosdevname=0 to the GRUB_CMDLINE_LINUX="..." value.
diff -u ~/grub.orig /etc/default/grub
--- /root/grub.orig 2012-10-04 20:04:11.145205513 -0400
+++ /etc/default/grub 2012-10-04 20:04:00.880206815 -0400
@@ -1,4 +1,4 @@
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Fedora"
GRUB_DEFAULT=saved
-GRUB_CMDLINE_LINE="rd.md=0 rd.lvm=0 rd.luks=0 LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us rd.dm=0"
+GRUB_CMDLINE_LINE="rd.md=0 rd.lvm=0 rd.luks=0 LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us rd.dm=0 biosdevname=0"
With this changed, re-generate the grub menu.
grub2-mkconfig -o /boot/grub2/grub.cfg
...
ifcfg-X Configuration Files
Unlike in past versions of this tutorial, we will no longer use the /etc/sysconfig/network-scripts/ifcfg-ethX file's HWADDR="..." values to map physical devices to DEVICE="..." names. Instead, we will create the mapping using the /etc/udev/rules.d/ folder.
Comment out the HWADDR="..." lines in all /etc/sysconfig/network-scripts/ifcfg-* files.
This is a good time to rename the configuration files and existing device names to what you want them to be. To do this, rename the file and the DEVICE="..." to the new name.
For example;
mv /etc/sysconfig/network-scripts/ifcfg-p2p1 /etc/sysconfig/network-scripts/ifcfg-eth3
sed -i 's/p2p1/eth3/g' /etc/sysconfig/network-scripts/ifcfg-eth3
Do this for all files which you wish to rename. For this tutorial, we reverted all network devices names to eth{0..5}.
Mapping MAC addresses to Physical Ports
Before we can remap the network devices to device names, we must first learn which ports have what MAC addresses. An easy way to do this is to edit each ifcfg-X file, set ONBOOT="yes" and change the protocol to BOOTPROTO="none". This will start each interface but will not assign an IP address.
Now, we want to disable NetworkManager and enable the traditional network daemon.
yum remove NetworkManager
chkconfig network on
chkconfig --list network
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Once these changes are done, you need to reboot.
Reboot.
Once back up, you should be see that all of the network devices have the names eth0 to eth5, assuming you have six network cards.
To identify which card has what MAC address, tail -f the system log and then, one at a time, unplug each cable. As you do so, note what name is reported as going down and then back up. Note at the same time which name you want that device to be.
For example;
Current Name | Desired Name |
---|---|
eth1 | eth0 |
eth0 | eth1 |
eth3 | eth2 |
eth4 | eth3 |
eth5 | eth4 |
eth2 | eth5 |
With this list, we can now edit the names assigned to the given MAC addresses in the next step.
udev Rules
As mentioned above, we will use the udev file to control MAC address to device name mapping.
Fedora 17+
In Fedora 17+, the file /etc/udev/rules.d/70-persistent-net.rules is no longer editable. Trying to modify it will simply end with it being re-written. To bypass this, we will create a blank, immutable file and put the contents we want in /etc/udev/rules.d/69-persistent-net.rules.
(ToDo)
Fedora 16-
In earlier versions, you can directly edit the existing /etc/udev/rules.d/70-persistent-net.rules file.
The udev Rules File
As always, start with a backup.
cp /etc/udev/rules.d/70-persistent-net.rules ~/
The format of this file is as follows;
# Comment on where the device was found
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:11:22:33:44:55", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="ethX"
The two parts we are interested in are:
- ATTR{address}=="..."; The MAC address of the interface we want to name. This must be entered using lower-case letters!
- NAME="ethX"; The name we wish to give this device, which must match the DEVICE="..." value in the appropriate ifcfg-ethX file.
Note: In this tutorial, we are simply reverting back to the old-style ethX names. This can be anything you like though. All that matters is that the udev's NAME="..." matches the ifcfg-... file's DEVICE="..." name. |
Making The Changes
The existing file should include all of your network cards. Armed with the old name to new name notes we wrote earlier, we just need to set the NAME="..." attribute to the new name we desire.
Once updated, reboot.
If everything worked, after the reboot, you should have all of your network devices with the new names. You can check this by again tail -f'ing the syslog and, one by one, unplug the cables and confirm that the log reports the properly named device going down and coming back up.
Done!
Any questions, feedback, advice, complaints or meanderings are welcome. | |||
Alteeve's Niche! | Enterprise Support: Alteeve Support |
Community Support | |
© Alteeve's Niche! Inc. 1997-2024 | Anvil! "Intelligent Availability®" Platform | ||
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions. |