Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to set a name for an interface, "ethLan" instead of eth0. Doing so also ensures that the if's name will remain consistent at every reboot and kernel.

I did find some articles in the subject, but they are all a couple of years old:
http://www.debian-administration.org/articles/463
http://www.linuxfromscratch.org/hints/downloads/files/nameif.txt

I did as they said and added the ethLan mac to /etc/mactabs/. At this point I have two problems:
1) The if [...] && /sbin/nameif script I put at /etc/network/if-pre-up.d/ does not run. I solved this by adding this to the /etc/init.d/networking, but why doesn't if-pre-up.d work?
2) The interface won't load unless I manually do ifconfig ethLan up, in spite of adding it to /etc/network/interfaces. What am I doing wrong?

share|improve this question
add comment

2 Answers

The articles you found are somewhat outdated. There is now an easy method to assign names to network interfaces, through Udev.

On Debian and derivatives (including Ubuntu), look out for a file called /etc/udev/rules.d/70-persistent-net.rules. This file is created by /lib/udev/rules.d/75-persistent-net-generator.rules with the help of the script /lib/udev/write_net_rules. Each time udev sees a new network device, it will assign it a new number and append that number to /etc/udev/rules.d/70-persistent-net.rules. That way, interface numbers are persistent across reboots, and will persist after a reinstallation if you restore /etc.

(If your distribution doesn't ship these files, look for them in the Debian package.)

If you want to give a meaningful name to an interface and you have /etc/udev/rules.d/70-persistent-net.rules, all you need to do is to edit that file and change "eth0" to "ethLan". Run udevadm trigger --sysname eth0 to rename the existing device after you've edited the file (I think this requires shutting down the interface). If you don't have that file, you can write the one-line matching yourself (the complicated scripts that Debian adds are only to do this automatically):

SUBSYSTEM=="net", DRIVERS=="?*", ATTR{address}=="01:23:45:67:89:ab", NAME="ethLan"
share|improve this answer
add comment

There is a slightly simpler way to do that with a package named ifrename. It has a separate (from udev) configuration file and you can use MAC addresses to identify interfaces.

It conflicts with wireless-tools however.

share|improve this answer
    
It should be noted that ifrename will conflict with udev if both are used to give interfaces persistent names. –  Mischa Arefiev Jan 12 '12 at 9:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.