Changing Ethernet Device Names in EL7 and Fedora 15+

From Alteeve Wiki
Revision as of 20:58, 7 October 2012 by Digimer (talk | contribs)
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. :)

Traditionally in Linux, network devices were given the name ethX, where X was a digit starting at 0 and incremented up. The drawback to this was that there was no consistent or deterministic way to know which physical network ports would get which ethX name. To address this, Fedora 15 (and other distributions) began using a new tool called biosdevname which names each network device based on where it is found in the system. The result is that, usually, you can predict the name of a given physical interface.

This tutorial will show you how to change these device names to anything you would like. This tutorial is not meant to advocate against the new network naming. However, there are cases ranging from simple familiarity to application compatibility that might make you want to use different network device names. For those cases, this tutorial hopes to help you.

Assumptions

This tutorial makes a few assumption which may not apply to your system. Please adjust accordingly.

This tutorial assumes you have six network cards;

  • p1p1
  • p1p2
  • p2p1
  • p2p2
  • p4p1
  • p4p2

We will rename these to;

  • bcn1
  • bcn2
  • sn1
  • sn2
  • ifn1
  • ifn2

The reason for these names is that, in my case, I wish to give names to interfaces that reflect their purpose in my servers. Specifically, I need three bonded networks; BCN, SN and IFN in my clusters. You can just as easily use eth0 to eth5 or any other name that suits your purposes.

This tutorial also assumes that you have a minimal install and that the system is designed to be a server. As such, NetworkManager is removed and the network daemon will be used. No attempt was made to test if the method of renaming network devices shown here works with NetworkManager.

Overview

We will need to take the following steps;

  1. Identify the network device names assigned to each interface.
  2. Generate the /etc/udev/rules.d/70-persistent-net.rules file.
  3. Unplug and plug back in each network interface to create the map of current to desired names.
  4. Rename and edit the /etc/sysconfig/network-scripts/ifcfg-X files to reflect the desired names.
  5. Edit the /etc/udev/rules.d/70-persistent-net.rules file to create the MAC address to device name maps.
  6. Restart the machine to make the changes take effect.

Identify Interfaces

To start, you want to see what the names your system has already given to the network interfaces. This can be done with iptables -a, which reports all network cards, regardless if they are started or not.

ifconfig -a
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 16436
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

p1p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::21b:21ff:fe72:99ab  prefixlen 64  scopeid 0x20<link>
        ether 00:1b:21:72:99:ab  txqueuelen 1000  (Ethernet)
        RX packets 2103  bytes 198150 (193.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 270 (270.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xf7ec0000-f7ee0000  

p1p2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::2e0:81ff:fecb:80  prefixlen 64  scopeid 0x20<link>
        ether 00:e0:81:cb:00:80  txqueuelen 1000  (Ethernet)
        RX packets 2102  bytes 197804 (193.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 270 (270.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17  memory 0xf7b00000-f7b20000  

p2p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.255.0.151  netmask 255.255.0.0  broadcast 10.255.255.255
        inet6 fe80::21b:21ff:febf:6c87  prefixlen 64  scopeid 0x20<link>
        ether 00:1b:21:bf:6c:87  txqueuelen 1000  (Ethernet)
        RX packets 2179  bytes 208690 (203.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 76  bytes 14361 (14.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17  memory 0xf7dc0000-f7de0000  

p2p2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::2e0:81ff:fecb:81  prefixlen 64  scopeid 0x20<link>
        ether 00:e0:81:cb:00:81  txqueuelen 1000  (Ethernet)
        RX packets 2102  bytes 197804 (193.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 270 (270.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 18  memory 0xf7a00000-f7a20000  

p4p1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::21b:21ff:febf:7002  prefixlen 64  scopeid 0x20<link>
        ether 00:1b:21:bf:70:02  txqueuelen 1000  (Ethernet)
        RX packets 2103  bytes 198150 (193.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 270 (270.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  memory 0xf7cc0000-f7ce0000  

p4p2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::21b:21ff:fe72:9692  prefixlen 64  scopeid 0x20<link>
        ether 00:1b:21:72:96:92  txqueuelen 1000  (Ethernet)
        RX packets 2101  bytes 197740 (193.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 270 (270.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xf79c0000-f79e0000

So I see the six network cards named pXpY. You might have emX, ethX or similar. The current names themselves doesn't matter too much, so long as you see all of your cards.

So now that we know which cards you have, we need to sort out which name maps to which device. There are several ways you can do this;

  • Sorting out the Consistent Network Device Names to physical interfaces. I find this to be an imperfect art.
  • Use ethtool -p <dev> and watch to see which port's light blinks. This requires driver support and a clear view of the network cards.
  • Watch the system log and unplug each cable to see what device is reported as having disconnected. This isn't the most elegant, but it is the method I prefer and which we will use here.

Before we proceed, let me give some background on what is happening behind the scenes.

In my case, I have three networks, each bonded across two interfaces, each link going to a separate switch (switch 1 and switch 2). I want to name these devices after their purpose;

Before I started, I figured out which physical port I wanted to use for a given network and link. You will obviously have your own plan and it will likely differ from the one shown here. This is no problem at all. So long as you know what name you want to give each physical interface, you are ready to go.

I start by creating a list on paper

Current Name Desired Name
p2p2 bcn1
p2p1 bcn2
p1p2 sn1
p4p1 sn2
p1p1 ifn1
p4p2 ifn2

 

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.