Change Default Network Name (ens33) to eth0 on Debian 10 / Debian 9

4

Debian 10 / Debian 9 uses a consistent and predictable device name for network interfaces. This predictable device naming helps us to locate network interfaces where it is connected like whether it is attached to onboard or external.

If you ever interested in changing interface name to eth0, then this is the tutorial for you.

Current Network Interface Name

Use the ip a command to see the network interfaces.

ip a
Interface Name Before Disabling Consistent Device Naming
Interface Name Before Disabling Consistent Device Naming

As you can see in the below output of ip a command, my Debian system is having a network adapter called enp0s3.

This is just the case of VirtualBox and it may vary depends on your system hardware (In the case of VMware, it will be ens33) but the procedure to get the ethX back will be the same.

You can confirm that the Ethernet device got renamed during the system boot by using the dmesg command.

sudo dmesg | grep -i eth
Kernel renamed eth0
Kernel renamed eth0

Disable Consistent Interface Device Naming

To regain the ethX back, edit the grub file.

sudo nano /etc/default/grub

Look for GRUB_CMDLINE_LINUX line and add net.ifnames=0 biosdevname=0.

FROM:

GRUB_CMDLINE_LINUX=""

TO:

GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
Edit GRUB Parameter
Edit GRUB Parameter

Generate a new grub configuration file using the grub-mkconfig command.

sudo grub-mkconfig -o /boot/grub/grub.cfg
Generate GRUB Configuration
Generate GRUB Configuration

Update Network Interface Configurations

Network Manager

If your system uses NetworkManager for network configuration, then you do not have to modify any settings. You can go ahead and reboot the system.

sudo reboot

Interfaces File

Edit the interface file and change the name of the network device so that you will have a DHCP/static IP address for ethX.

DHCP

If your machine is on a DHCP network, then,

sudo nano /etc/network/interfaces

Update below lines in interface files so that the network card can get an IP address from the DHCP server.

FROM:

auto ens33
iface ens33 inet dhcp

TO:

auto eth0
iface eth0 inet dhcp

Static

If your infrastructure does not have a DHCP server, then you may need to configure a static IP address for the network interface.

sudo nano /etc/network/interfaces

FROM:

auto ens33
iface ens33 inet static
           address 192.168.0.10
           netmask 255.255.255.0
           dns-nameservers 192.168.0.1
           gateway 192.168.0.1

TO:

auto eth0
iface eth0 inet static
           address 192.168.0.10
           netmask 255.255.255.0
           dns-nameservers 192.168.0.1
           gateway 192.168.0.1

Reboot your system.

sudo reboot

Verify Network Interface Name

After the system reboot, go and check whether you have got the eth0 back.

ip a
Interface Name After Disabling Consistent Interface Device Naming
Interface Name After Disabling Consistent Interface Device Naming

Conclusion

That’s All. Please drop your feedbacks in the comments section.

You might also like