Vai al contenuto
Home » Renaming Network Interfaces on Linux to eth0

Renaming Network Interfaces on Linux to eth0

Renaming Network Interfaces on Linux to eth0
Renaming Network Interfaces on Linux to eth0

 

How to rename network interfaces on SysLinuxOS and Debian Gnu/Linux permanently to eth0, eth1, wlan0. These names (eno1, enp5s0, wlp3s0, enp2s0, wlp2s0) are not always intuitive, especially when using multiple interfaces on the same machine.These are assigned to network interfaces directly by the kernel. To make network interface names more descriptive and easier to manage, we can rename them using the systemd-networkd service. All these names have in common the first two letters, “en” and “wl“. In fact, if you type the command:

sudo dmesg | grep -i eth
sudo dmesg | grep -i wl

you can read that the interfaces are renamed starting from eth0 and wlan0. Personally, I know two working methods to return to the old standard.

The First

this way should work in most cases and just do a small addition to grub:

sudo nano /etc/default/grub

add:

GRUB_CMDLINE_LINUX=”net.ifnames=0 biosdevname=0″

as below:

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=”quiet”

generate a new grub config file, and reboot.

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

If everything went well, the interfaces will be eth0 and wlan0. If you’re using DHCP, there’s no need to modify anything. In case of a static IP, you can use the usual method:

sudo nano /etc/network/interfaces

 

auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
dns-nameservers 192.168.1.1
gateway 192.168.1.1

The Second

This alternative method involves finding the names and paths of the current network cards and then manually creating two files that will contain the new names.

sudo udevadm info /sys/class/net/name_interface

The command above finds the data we’re interested in

E: ID_PATH=pci-0000:03:00.0
E: ID_PATH_TAG=pci-0000_03_00_0

now we will be able to create the file manually:

sudo nano /etc/systemd/network/10-rename-name_interface

example below for eth0:

[Match]
Path=pci-0000:03:00.0
pci-0000_03_00_0
[Link]
Name=eth0

for wlan0

[Match]
Path=pci-0000:05:00.0
pci-0000_05_00_0
[Link]
Name=wlan0

After the reboot, the name of the network interfaces will be permanently seen with the old standard. In reality, there is also another method, simpler 🙂 , which is a bash script that does everything automatically:

rename-interfaces.sh

git clone https://github.com/fconidi/rename-interfaces.git
cd rename-interfaces/
chmod +x rename-interfaces.sh
sudo ./rename-interfaces.sh
sudo reboot

Renaming Network Interfaces on Linux to eth0

enjoy 😉

 

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *