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.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
Method 2
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
Method 3
I found a very easy way by changing only /etc/network/interfaces:
rename enp3s0=wan0
Then
service networking restart
to restart the networking service.
Method 4
These days systemd.link – Network device configuration offers a comfortable method to rename interfaces persistently.
Method 5
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"
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0