== Fixing Ubuntu's ethN device names when you swap hardware If you swap an Ubuntu 6.06 system disk between hardware units (even nominally identical hardware units, like from one Dell 2950 to another PE2950), the system will come up scrambled Ethernet devices and you won't be on the network. (As we found out the hard way today.) This happens because the only way Ethernet devices get consistent numbers on Ubuntu machines is because Ubuntu remembers the mapping between hardware ethernet addresses and the ethN name that they should get. When you transplant hardware, the hardware addresses change, nothing matches up any more, and your Ethernet NICs get random names. (This also means that _eth0_ in kernel messages is usually not the device that _ifconfig eth0_ is talking about.) _/etc/iftab_ has the ethN {{C:harr}} hardware ethernet address mapping; unknown hardware addresses will be given ethN names that are not in use in here. _/etc/network/interfaces_ tells you what ethN names you are using for what actual network connections. Because Ubuntu seems to more or less randomly renumbers ethN devices on each reboot, you can't just remove _/etc/iftab_, fix your _interfaces_ file to use the 'natural' names, and be done. Instead you have to reconstruct it with the right MAC addresses for any interfaces you care about. Steps to do this: * look at _/etc/network/interfaces_ to find out what ethN names you care about. * find out what current ethN names are connected to the network: _cd /sys/class/net_ \\ _for i in eth*; do ifconfig $i up; done_ \\ _dmesg | tail -10_ Now look for devices that have reported that their link is up. If you are lucky, the machine only has one network connection and you are done. If the machine has multiple network connections you will need to use various means (eg, unplugging and replugging network cables and watching kernel messages) to figure out which ethN name is which connection. * look up the MAC of each interface you care about with _ifconfig eth~~N~~_, and edit _/etc/iftab_ to update the MAC for the 'correct' name for that interface. Delete every other ethN name in _iftab_, just so they don't confuse anyone. Once you have updated everything you care about, reboot. Optionally and possibly later, add name/MAC mappings for *everything* to _iftab_, so that if you add another network connection in the future it's sure to have a stable name. If you do this you will want to map out what each physical port's Ethernet address is, so that you can assign the names in a consistent and logical way and do things like make sure that a card with two NICs gets two consecutive ethN names. For bonus charm _iftab_ is apparently being deprecated in favour of another way of doing this, so the next Ubuntu LTS release will probably require an entirely different way of fixing this. (Of course, Ubuntu does not supply a convenient program to (re)build an _iftab_ for you.) === Sidebar: on the random renumbering issue If a kernel device driver is responsible for more than one Ethernet device, it always reports them in a consistent internal order. If you have no _iftab_ file, Ubuntu will probably only reorder blocks of ethN devices served by different drivers. Eg, if you have four Intel NICs and two Broadcom NICs, the internal order in the Intel NICs and the Broadcom NICs is probably always going to be consistent, and the first Intel NIC will be either eth0 (Intel driver loaded first) or eth2 (Broadcom driver loaded first). However, which driver is loaded first seems to be more or less random. If Ubuntu does have an _iftab_ file it will rename the kernel's initial ethN names to not use any ethN name claimed by _iftab_, and I believe the order it does this renaming is really random and can completely shuffle ethN names, so that if _iftab_ claims eth0 through eth3, you could have eth4 being the third Intel NIC, eth5 being the first Broadcom NIC, and so on.