Debian Clusters for Education and Research: The Missing Manual

Udev: Renaming Network Interfaces

From Debian Clusters

Jump to: navigation, search

Contents

Network Interfaces (NICs)

When you type

ifconfig

each network interface has a name. These are usually lo, the internal loopback device that isn't really an interface, and ethX where X starts at 0 and continues up depending on how many network interfaces (sometimes called NICs) the machine has. These can actually be renamed to anything else, as long as the name is short.

In several other places, I've given examples of a setup for another cluster at my school that runs over three interfaces. It keeps three domain names - gig0, gig1, and fe0. Gig0 and gig1 are over Gigabit Ethernet, while fe0 is over FastEthernet. To help remember which domain is over which interface, the three interfaces on each machine have been renamed from eth0, eth1, and eth2 to gig0, gig1, and fe0.

Udev

Udev is responsible for managing devices on a Linux system. This includes everything from hard drives and RAM to, you guessed it, network cards (NICs). As part of this, udev assigns names and IDs to these devices, including the name that users will use to refer to the device.

If you've ever moved a hard drive from one computer to another, you might notice that the network interface used to be eth0 and it's now become eth1. What's up with that? The reason this happens is that udev stores its information about the network cards, even though this is automatically populated. When the new computer boots up for the first time, udev sees that the current NIC doesn't match the one it previously had, and so it creates a new entry and increments the number after eth. This is why the udev entries should also be cleared before cloning a hard drive image.

Old NICs can be deleted from udev and current ones can be renamed.

/etc/udev/rules.d/z25_persistent-net.rules

z25_persistent-net.rules is the file responsible for the names of the network interfaces. A typical line looks like this.

# PCI device 0x10de:0x0373 (forcedeth)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:e0:81:75:94:31", NAME="eth1"

Changing the value of NAME is all that's necessary to change a NIC's name. Similarly, to delete an old NIC, just delete the line. Then either reboot or restart udev. To restart udev, run

/etc/init.d/udev restart

References

Personal tools