Getting eth0 back (from p9p1, em0, etc.) on your Linux machine

I have had a problem on my Linux server (Ubuntu 13.04) for quite a while. I do not have eth0 but a network device called p9p1. It causes me many troubles, especially when I install commercial software for Linux platform, e.g., MATLAB for Linux. The installation program needs to find ethX in order to bind the license with the MAC address of my computer. But since there is no eth0, installation programs of those commercial tools give me a lot of headache, until today.

After dinner, I did some googling and found out the solution is as simple as editing /etc/udev/rules.d/70-persistent-net.rules. If the device's MAC address is FF:FF:FF:FF:FF:FF and you wanna call it eth0, then add this line
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ff:ff:ff:ff:ff:ff", NAME="eth0"
into
/etc/udev/rules.d/70-persistent-net.rules

Do NOT reboot now!

If you are remotely log into your machine to do this, make sure to take care /etc/network/interfaces before you reboot. Otherwise, you won't be able to log in via network again. Go to corresponding lines in /etc/network/interfaces and replace the old device name (e.g., p9p1) by the new one, e.g., eth0. For example, I replaced
auto p9p1
iface p9p1 inet dhcp
by
auto eth0
iface eth0 inet dhcp

Done!

I don't have time to explain details here but it seems to be related to how Linux determines logical name of network devices and how their names are passed from BIOS. The problem on my server seems to be rare because it took me quite a lot of time to google the solution, and my /etc/udev/rules.d/70-persistent-net.rules is just empty - there should be something automatically filled.

Update for Ubuntu 14.04 LTS Server: Some users report that you also need to tweak one line in Grub to make this method work. Here is the link. Luckily, I didn't have such problem on my Ubuntu 14.04 LTS system.

References:
1. Intel e1000e nic seen as em0 instead of eth0, Ubuntu Forum, http://ubuntuforums.org/showthread.php?t=2146205
2. Network Configuration, Ubuntu 10.04 Official Documentation, https://help.ubuntu.com/10.04/serverguide/network-configuration.html [See the subsection called "Ethernet Interface Logical Name"]

2 comments:

Bill Lopes said...

Thanks Forrest, that worked for me. I did not have to tweak the GRUB line either.

Gary Nowels said...

Thanks, Worked great for ease of identifying multiple interfaces.