How to change Network Interface Name on Debian 11.3

To Change Network Interface Name on Debian 11.3

Introduction:

Generally, a Network interface is named either eth0, eth1, eth2 and etc. The network interface name depends on the Ethernet connections available and its number should vary from eth0 to eth1. Once Debian 11.3 is installed, the network interface name gets changed from eth0 to ens33. It is quite easy to change the Network Interface name on your Debian machine and this article can help you with that.

Procedure:

Step 1: Check the OS Version by using the below command

[root@linuxhelp: ~#] lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 11 (bullseye)
Release:	11	
Codename:	bullseye

Step 2: Verify your network interface name using ‘ifconfig’ command or ‘ip a’ command.

[root@linuxhelp: ~#] sudo ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.6.127  netmask 255.255.254.0  broadcast 192.168.7.255
        inet6 fe80::20c:29ff:fef7:6f3e  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:f7:6f:3e  txqueuelen 1000  (Ethernet)
        RX packets 20010  bytes 27736289 (26.4 MiB)
        RX errors 19  dropped 0  overruns 0  frame 0
        TX packets 8563  bytes 611840 (597.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 19  base 0x2000

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 48  bytes 4461 (4.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 48  bytes 4461 (4.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Step 3: Debian has it network interface name as eth0 while in boot time it will automatically renamed to ens33 to verify this using the below command.

[root@linuxhelp: ~#] dmesg | grep -i eth
[    4.499644] pcnet32: eth0: registered as PCnet/PCI II 79C970A
[    4.652648] pcnet32 0000:02:01.0 ens33: renamed from eth0

Step 4: In order to change Network Interface name, we require to edit grub configuration file by using the below commands.

[root@linuxhelp: ~#] vim /etc/default/grub

Add the following lines to it.
GRUB_CMDLINE_LINUX=" net.ifnames=0 biosdevname=0" 

Step 5: Next regenerate grub configuration file by using the below command.

[root@linuxhelp: ~#] sudo grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-5.10.0-16-amd64
Found initrd image: /boot/initrd.img-5.10.0-16-amd64
Done

Step 6: Now open the network interface file by running the below command.

[root@linuxhelp: ~#] vim /etc/network/interfaces
Add the following content to it.
auto eth0
iface eth0 inet static
           address 192.168.5.152
           netmask 255.255.255.0
           dns-nameservers 8.8.8.8
           gateway 192.168.5.1

Step 7: Next reboot your system and check network interface name once again with ‘ipconfig’ command.

[root@linuxhelp: ~#] sudo init 6
[root@linuxhelp: ~#] sudo ifconfig
eth0     Link encap:Ethernet  HWaddr 00:0c:29:31:3d:a8  
          inet addr:192.168.5.152  Bcast:192.168.5.255  Mask:255.255.255.0
          inet6 addr: fe80::fde3:373:9789:718f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:259066 errors:0 dropped:0 overruns:0 frame:0
          TX packets:157287 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:390546979 (390.5 MB)  TX bytes:10853428 (10.8 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:245 errors:0 dropped:0 overruns:0 frame:0
          TX packets:245 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:20220 (20.2 KB)  TX bytes:20220 (20.2 KB)

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to change Network interface name Debian 11.3. Your feedback is much welcome

FAQ
Q
What is eth0 used for?
A
eth0—Use the eth0 interface to configure the virtual IP (VIP) address of fabric and the IP address of the node as well as to access the managed devices. The VIP address and the IP address of the node should be on the same subnet.
Q
What are the 4 types of IP addresses?
A
An internet protocol (IP) address allows computers to send and receive information. There are four types of IP addresses: public, private, static, and dynamic.
Q
What is IP in Linux?
A
Ip command in Linux is present in the net tools which are used for performing several network administration tasks. IP stands for Internet Protocol. This command is used to show or manipulate routing, devices, and tunnels.
Q
What is the IP address from ifconfig?
A
The system will display all network connections – including connected, disconnected, and virtual. Look for the one labeled UP, BROADCAST, RUNNING, or MULTICAST to find your IP address. This lists both IPv4 and IPv6 addresses.
Q
What is ifconfig for Linux?
A
Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed. If no arguments are given, ifconfig displays the status of the currently active interfaces.