Ethernet numbering in Ubuntu

update: this info is obsolete as of Ubuntu Gutsy (7.10). ‘Bogdan’ posted a comment with an approach that works on more modern Ubuntus:

In recent Ubuntu versions (and potentially other Linuxes), the iftab file is replaced by /etc/udev/rules.d/70-persistent-net.rules

(The 70 might change, though.)

It’s not the same syntax, but you can tell rather easily what it does.


My girlfriend’s laptop got bricked, so we replaced it with another laptop of the same make and model, and put in her original laptop’s harddisk. Of course, Ubuntu ran fine, but there was one issue: instead of having eth0 and eth1 as WiFi and LAN devices, we had eth2 and eth3. For some reason, Ubuntu refused to re-use eth0 and eth1.

After a bit of digging, I found out that /etc/iftab contains the MAC addresses of network cards:

# This file assigns persistent names to network
# interfaces. See iftab(5).
eth0 mac 00:01:de:ad:be:ef

This is very useful if you have hot-pluggable NICs that need to keep the same ethX every time you plug them in. Ubuntu’s installation put in the MAC addresses of the original network interfaces, so that’s why the new hardware skipped eth0 and eth1 and used eth2 and eth3.

Setting the correct MAC addresses in /etc/iftab solved the issue.

dr. Sybren A. Stüvel
dr. Sybren A. Stüvel
Open Source software developer, photographer, drummer

Related