Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

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

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
If you want a handy list of attributes usable in udev rules, you can try something like udevadm info -a /sys/class/net/eth0. (see udevadm(8) for details) – Austin Adams Aug 21 '15 at 1:18
The question clearly states to be for Wheezy, yet it might be worth noting that this answer is no longer valid for newer Debian and Ubuntu. Starting with systemd 220-7 interface naming needs to be done via other means. – sampi May 27 at 15:36
@sampi My answer still applies to Debian jessie (the current stable release). Does it fail on stretch, or is it just recommending a deprecated method? Do you know which release of Ubuntu is the cutoff? – Gilles May 27 at 15:51
@Gilles I did not dig deep enough into the details in order to know whether it actually fails or merely is a recommended deprecation. It seems Ubuntu Wily and newer use systemd higher than 220-7. – sampi May 30 at 13:28

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

Your Answer


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.