You've probably noticed that the recent trend in some Linux distributions is to name network cards not by ethX, but by their chipset. So we end up with em0, em1 or whatever...
This idea probably came from Solaris, but personally, I don't see the benefit, especially since it's more of a hindrance when you want to standardize an IT infrastructure. The purpose of this article is to show how to return to the good old ethX interfaces. I recommend reading the article on Udev before starting this one, to better understand certain aspects.
Implementation
Grub
We're going to add this argument (biosdevname=0) to the classic grub line to indicate at boot that we don't want the interface renaming to take effect. Here's an example:
# 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, and change only the value of the NAME= key.SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="d4:ae:52:9b:5a:85",ATTR{type}=="1",KERNEL=="eth*",NAME="eth0"
Or simply delete the file (I've encountered cases where this didn't work).
Configuration Files
You will then need to modify your network configurations and set the correct interfaces.
Debian
For example, on Debian, you'll need to adapt the /etc/network/interfaces configuration with the correct interfaces (ethX).
Red Hat
On Red Hat, you'll need to rename the /etc/sysconfig/network-scripts/ifcfg-* interfaces and enter each of them to set the associated devices. For this Red Hat part, I find it so tedious that I made a script that will automatically modify udev and interfaces. Here it is:
#!/bin/bash# Made by Pierre Mavro / Deimos# This script rename interfaces to get ethX instead of chipset name# Backup existing fileif[-e/etc/udev/rules.d/70-persistent-net.rules];thencp/etc/udev/rules.d/70-persistent-net.rules{,.bak}fi# Generate 70-persistent-net.rules fileecho"# Generated by Kickstart/Puppet# 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, and change only the value of the NAME= key.">/etc/udev/rules.d/70-persistent-net.rules
i=0formin`iplinkshow|grep"^\s*link"|grep-vloopback|uniq|sort|awk'{ print $2 }'`;do# Change sysconfig filemyifname=$(grep-li"$m"/etc/sysconfig/network-scripts/ifcfg-*|awk-F'ifcfg-''{ print $2 }'|grep-vbond)perl-pi-e"s/^DEVICE=.*/DEVICE=\"eth$i\"/"/etc/sysconfig/network-scripts/ifcfg-$myifnamemv/etc/sysconfig/network-scripts/ifcfg-{$myifname,eth$i}# Change udev ruleecho'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$m'", ATTR{type}=="1", KERNEL=="eth*", NAME="eth'$i'"'>>/etc/udev/rules.d/70-persistent-net.rules
echo''>>/etc/udev/rules.d/70-persistent-net.rules
leti++
done