19

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.

6 Answers 6

30

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
  • 1
    Where can is this info found in the official Linux documentation?
    – vfclists
    Commented Sep 18, 2018 at 14:13
  • 2
    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
    Commented Mar 22, 2022 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 ? Commented 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
    Commented Oct 6, 2017 at 13:10
  • Thanks, this is a nice addon, I will point the temporary solution to your answer aswell :) Commented 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
    Commented 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
    Commented Jul 6, 2021 at 10:48
1

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"
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
    Commented May 18, 2021 at 19:05
0

There are simple steps to follow.

  1. Open Terminal and type

    sudo nano /etc/default/grub
    
  2. Comment the line GRUB_CMDLINE_LINUX_DEFAULT="quiet" as per shown in the below screenshot.

    enter image description here

    Add new line GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames=0 biosdevname=0"

    Press X then y for save and exit.

  3. Type

    grub2-mkconfig -o /boot/grub2/grub. cfg
    
  4. reboot the machine. Done!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .