How to Change Network Interface name on Ubuntu

To change Network Interface name on Ubuntu

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

Changing the Network Interface name

You can verify your network interface name using ‘ ifconfig’ command or ‘ ip a’ command.

root@linuxhelp1:~# ifconfig 
ens33     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:218283 errors:0 dropped:0 overruns:0 frame:0
          TX packets:134051 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:328932569 (328.9 MB)  TX bytes:9267462 (9.2 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:241 errors:0 dropped:0 overruns:0 frame:0
          TX packets:241 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:19860 (19.8 KB)  TX bytes:19860 (19.8 KB)

Ubuntu has it network interface name as eth0 while in boot time it will automatically renamed to ens33 to verify this on use the below command.

root@linuxhelp1:~# dmesg | grep -i eth
[    1.768429] e1000 0000:02:01.0 eth0: (PCI:66MHz:32-bit) 00:0c:29:31:3d:a8
[    1.768435] e1000 0000:02:01.0 eth0: Intel(R) PRO/1000 Network Connection
[    1.778278] e1000 0000:02:01.0 ens33: renamed from eth0

In order to change Network Interface name we require to edit grub configuration file as shown below.

root@linuxhelp1:~# vim /etc/default/grub

Add the following lines to it.

GRUB_CMDLINE_LINUX=" net.ifnames=0 biosdevname=0" 

Next regenerate grub configuration file.

root@linuxhelp1:~# grub-mkconfig -o /boot/grub/grub.cfg
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.4.0-64-generic
Found initrd image: /boot/initrd.img-4.4.0-64-generic
Found linux image: /boot/vmlinuz-4.4.0-21-generic
Found initrd image: /boot/initrd.img-4.4.0-21-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Done

Now open the network interface file by running the following commnad.

root@linuxhelp1:~# 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

Now that’ s all just you need to reboot your system and check network interface name once again with ‘ ifconfig’ command

root@linuxhelp1:~# 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)

The network interface has been changed now. Changing the network interface was quite easy wasn' t it? Having your network interface changed may help you a lot.

Tag : Ubuntu
FAQ
Q
"How do I select the best cable for the job?
A
While Network Cables do look alike from the outside and they all have the same connectors, they can have significant differences on the inside. You can find out the type of cable you have by looking at the text printed on the side of the cable.
Q
What are the Different categories of cable and what do the different categories mean?
A
Co-Axial - Co-Axial came in Thinnet and Thicknet, both standards are now defunct and no longer in use. Twisted Pair - Twisted Pair came in several combinations and categories (CAT3, 4, 5, etc.).
Q
What is a NIC port and What does it do?
A
"A Port or Connector :
A Port or Connector on a Dell PC has either holes or a slot that matches the plug or device that you are connecting to the Port.
"
Q
What is the future of the NIC port?
A
"There doesn't appear to any doubt that the NIC standard has a very clear-cut advantage in transfer speeds and in how widely spread it is.
Q
"How can I see what it does and control its activity?
A
On Windows, open your Windows Control Panel, then click the icon or link to the Akamai NetSession Interface Control Panel.