Changing Ethernet Device Names in EL7 and Fedora 15+

From Alteeve Wiki
Revision as of 00:51, 5 October 2012 by Digimer (talk | contribs) (Created page with "{{howto_header}} {{warning|1=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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

 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
...

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.

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.

udev Rules

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.


 

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.