10

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.

17

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.

  • Where can is this info found in the official Linux documentation? – vfclists Sep 18 '18 at 14:13
3

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
  • 1
    Oh nice, however this isn't just a temporary change until the next reboot ? – user3450548 Oct 6 '17 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 '17 at 13:10
  • Thanks, this is a nice addon, I will point the temporary solution to your answer aswell :) – user3450548 Oct 7 '17 at 1:24
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.