This article will guide you to change the default network interface name in Debian 11 and older versions via command line. Usually, after a fresh Debian install from an ISO, the network interface will be named
ens3 by default. Some people may prefer changing it to
eth0 which is a more common name.
Checking the default interface name
You can list all the network interfaces using the
ip link command.
Usually, it’s the second one after the
lo interface. If it’s not
eth0 and you would like to change it, just follow the next step.
Editing the GRUB configuration file
Open the GRUB configuration file with your editor of choice. I’m using Vim in this tutorial.
sudo vi /etc/default/grub
Change the following line located at the top section of the file
Save changes and exit the text editor.
Editing the network configuration file
Open the network configuration file located at the following path.
sudo vi /etc/network/interfaces
Change the network interface name from
eth0 for both IPv4 and IPv6 if any. Save changes and exit.
auto lo iface lo inet loopback auto eth0 iface eth0 inet static # IPv4 configuration here iface eth0 inet6 static # IPv6 configuration here
Updating GRUB and rebooting
After editing the GRUB configuration file and changing the default interface name to
eth0 in the network configuration file, you have to update GRUB using the following command accordingly. And reboot the server for changes to take effect.
sudo update-grub2 sudo reboot