Posted by Steve on Fri 23 Feb 2007 at 11:54
If you have multiple ethernet devices upon a system it is useful to make sure they are always given the device names that you expect. This can be useful when you're managing upgrades - or for situations where you accidentally setup a system with eth1 plugged into a switch rather than eth0.
There are several different ways of managing the naming of devices if you're using a dynamic /dev system such as udev or hotplug - but the simplest system which works for most cases is provided by the ifrename package.
Once installed this package will let you rename devices based upon something that shouldn't change their MAC addresses. (Finding MAC addresses of an ethernet device is simple.)
First of all you must install the package:
root@mine:~# apt-get install ifrename Reading package lists... Done Building dependency tree... Done The following extra packages will be installed: libiw28 The following NEW packages will be installed ifrename libiw28 ..
Once installed you may create a new file /etc/iftab to define the mapping between your ethernet device's MAC addresses and the interface names.
The contents of this file should look similar to this:
eth0 mac 00:17:31:56:BC:2D eth1 mac 00:16:3E:2F:0E:9C
With this configuration file in place when you reboot next you'll discover that regardless of your kernel upgrading, that the network card with MAC address "00:17:31:56:BC:2D" will be setup as eth0, and that the card with MAC address "00:16:3E:2F:0E:9C" will be known as eth1.
(The actual renaming will happen automatically via the addition of /etc/init.d/ifrename.)
[ Parent ]
[ Parent ]
This has also been discussed on this site in some users' weblogs.
In etch, at least the files /etc/udev/persistent-net.rules and /etc/udev/persistent-net-generator.rules have a nice automagic interaction to keep nice stable names for your NICs.
[ Parent ]
[ Parent ]
easier to remember all around, plus when i plug in an unusual new interface, it can grab the generic "eth0" without my having to think about it.
[ Parent ]
I should have mentioned this as a good use for the package.
I tend not to bother with renaming devices except upon Xen hosts which have lots of vifN.0. interfaces.
[ Parent ]
[ Parent ]
Too true!
I just had to use the tool recently, and remembered it was one of the packages which has been sat on my articles to write pile for a while. So I figured I'd make a quick overview a couple of nights ago. It didn't cross my mind to search first!
[ Parent ]
[ Parent ]
SUBSYSTEM=="net", DRIVERS=="?*", SYSFS{address}=="00:13:72:89:79:26", NAME="eth0"
SUBSYSTEM=="net", DRIVERS=="?*", SYSFS{address}=="00:13:72:89:79:27", NAME="eth1"
You can edit that file by hand or use write_net_rules sh-script to fill it.
[ Parent ]