16

I would like to do 2 things:

1) Revert back the interfaces to the old classic name: eth0 instead of ens33.

2) Rename the interfaces in the way I want so that for example I can call interface eth0 as wan0 or assign eth1, eth2 and so on the mac address I want.

5 Answers 5

27

Assuming that you have just installed your debian 9 stretch.

1) For reverting back the old names for the interfaces do:

nano /etc/default/grub

edit the line GRUB_CMDLINE_LINUX="" to GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

then launch a grub-mkconfig for apply the changes inside the bootloader

grub-mkconfig -o /boot/grub/grub.cfg

You need a reboot after that.


2) For renaming the interfaces use:

  • For just a temporary modification take a look at the @xhienne answer.

  • For a permanent modification:

Start by creating / editing the /etc/udev/rules.d/70-persistent-net.rules file.

nano /etc/udev/rules.d/70-persistent-net.rules

And insert inside lines like:

# interface with MAC address "00:0c:30:50:48:a1" will be assigned "eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:30:50:48:a1", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# interface with MAC address "00:0c:30:50:48:ab" will be assigned "eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:30:50:48:ab", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

If you want to assign for example a name like wan0 to eth0 you can use given my example:

# interface with MAC address "00:0c:30:50:48:a1" will be assigned "eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:30:50:48:a1", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="wan0"

After the next reboot or using service networking restart you should see the changes applied.


EXTRA: Remember that after all this modifications you have to edit your /etc/network/interfaces file replacing the old interfaces names with the new ones!


EXTRA: If you want to know what MAC address your interfaces have, just do a

ip addr show

and look under the link/ section.

2
  • Where can is this info found in the official Linux documentation?
    – vfclists
    Sep 18, 2018 at 14:13
  • For debian this can be found here wiki.debian.org/NetworkInterfaceNames and also that biosdevname=0 is not required for debian but only for old RedHat and some other distributions.
    – Hannes
    Mar 22 at 8:15
7

For question 1) see user3450548's answer. For question 2) you can give any name you want to an interface with iproute2:

ip link set ens33 down           # Else you will get "Device or resource busy"
ip link set ens33 name eth0
3
  • 1
    Oh nice, however this isn't just a temporary change until the next reboot ? Oct 6, 2017 at 9:09
  • Yes. Of course you can add this in a startup script, but your answer is better if you want something permanent. I didn't notice you were answering your own question (you may accept it then) and added this if you (or anyone else) would like a temporary name change for testing purpose.
    – xhienne
    Oct 6, 2017 at 13:10
  • Thanks, this is a nice addon, I will point the temporary solution to your answer aswell :) Oct 7, 2017 at 1:24
2

I found a very easy way by changing only /etc/network/interfaces:

rename enp3s0=wan0

Then

service networking restart

to restart the networking service.

2
  • That looks really good. Because I struggled to find the offical documentation before: It is here manpages.debian.org/buster/ifupdown/interfaces.5.en.html , and rename is documented.
    – Jakob
    Jan 24, 2021 at 9:33
  • Using the keyword rename works only in the original ifupdown package; the replacement package ifupdown2 doesn't knows this keyword and restarting the service will fail with an error.
    – user762353
    Jul 6, 2021 at 10:48
1

These days systemd.link - Network device configuration offers a comfortable method to rename interfaces persistently.

1
  • 1
    Sorry, my bad. I have mixed it up with /etc/udev/rules.d/70-persistent-net.rules
    – user62469
    May 18, 2021 at 19:05
0

Create below file if not there

nano /etc/udev/rules.d/70-persistent-net.rules

add below line

# interface with MAC address "00:0c:30:50:48:a1" will be assigned "eth0"
# KERNEL=="enp3s0" is debians current interface name
# NAME="eth0" is a new ethernet interface name
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:30:50:48:a1", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="enp3s0", NAME="eth0"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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