Change default network name (ens33) to old “eth0” on Ubuntu 18.04 / Ubuntu 16.04

Just after the Ubuntu installation, I came to know that the network interface name got changed to ens33 from old school eth0.

READ: Install Ubuntu 18.04 LTS (Bionic Beaver) on UEFI and Legacy BIOS System

READ: Install Ubuntu 16.04 LTS (Xenial Xerus) – Step by Step Guide with Screenshots

If you ever interested in changing interface names to old type ethX, here is the tutorial for you.

As you can see in the following command, my system is having a network adapter called ens33.

This is just the case of VMware environment, it may vary depends on the hardware but the steps to get back ethX will be the same.

$ ip a

1: lo: <loopback,up,lower_up> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: </loopback,up,lower_up>ens33: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:05:a3:e2 brd ff:ff:ff:ff:ff:ff
    </broadcast,multicast,up,lower_up>inet 192.168.12.12/24 brd 192.168.12.255 scope global dynamic ens33
       valid_lft 1683sec preferred_lft 1683sec
    inet6 fe80::20c:29ff:fe05:a3e2/64 scope link
       valid_lft forever preferred_lft forever

From the dmesg command, you can see that the device got renamed during the system boot.

$ dmesg | grep -i eth

[    3.050064] e1000 0000:02:01.0 eth0: (PCI:66MHz:32-bit) 00:0c:29:05:a3:e2
[    3.050074] e1000 0000:02:01.0 eth0: Intel(R) PRO/1000 Network Connection
[    3.057410] e1000 0000:02:01.0 ens33: renamed from eth0

To get an ethX back, edit the grub file.

$ sudo nano /etc/default/grub

Look for “GRUB_CMDLINE_LINUX”  and add the following”net.ifnames=0 biosdevname=0“.

From:

GRUB_CMDLINE_LINUX=""

To:

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

Generate a new grub file using the following command.

$ sudo 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-15-generic
Found initrd image: /boot/initrd.img-4.4.0-15-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
done

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

READ: Install and configure DHCP server on CentOS 7 / Ubuntu 16.04 / Debian 9

Assign IP Address

For Ubuntu 18.04

You can assign an IP address to the system using netplan – a new network configuration tool.

READ: How To Configure Static IP Address in Ubuntu 18.04 using Netplan

For Ubuntu 16.04 / Older

DHCP:

If your infrastructure has a DHCP server and you want to leverage that, then:

$ sudo nano /etc/network/interfaces

Update below lines in /etc/network/interfaces files so that the network card can get an IP address from 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 will need to configure a static IP address for all network interfaces on your Ubuntu machine.

$ sudo nano /etc/network/interfaces

From:

auto ens33
iface ens33 inet static
           address 192.168.12.12
           netmask 255.255.255.0
           dns-nameservers 192.168.12.2
           gateway 192.168.12.2

To:

auto eth0
iface eth0 inet static
           address 192.168.12.12
           netmask 255.255.255.0
           dns-nameservers 192.168.12.2
           gateway 192.168.12.2

Reboot your system.

$ sudo reboot

After the system reboot, just check whether you have an ethX back.

$ ip a
1: lo: <loopback,up,lower_up> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: </loopback,up,lower_up>eth0: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:05:a3:e2 brd ff:ff:ff:ff:ff:ff
    </broadcast,multicast,up,lower_up>inet 192.168.12.12/24 brd 192.168.12.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe05:a3e2/64 scope link
       valid_lft forever preferred_lft forever

That’s All.

ubuntu 16.04ubuntu 18.04
Comments (37)
Add Comment
  • Shawn

    Ha. That worked for my issue #1.

    I wonder if you have any thoughts on why when I reboot/shutdown the system, the link drops (light off on the router), which disables the ability to WOL, a feature I use a lot. Even Windows 10 broke that from Windows 7. I’m reverting back to Linux after Windows 10 keeps crashing, blaming it on my nVidia driver dll file. No issues in Linux.

    What seems to happen is that the link is told to shutdown, or quit listening, and the link light goes off on the router. Sometime later, it does seem to come back on, as I can WOL in the morning and the link light is back on before I send a magic packet from my smartphone app.

    I would like to know what is turning the link completely off while the system shuts down for reboot or full shutdown.

    If I find the reason/cause/fix in the meantime, I will try to return here with my findings that may or may not help others.

  • Bakku

    thanks for this!

  • ww

    This way works for me.

    GRUB_CMDLINE_LINUX_DEFAULT=”quiet net.ifnames=0 biosdevname=0″

  • xilsoe

    Thanks. Works for me.

  • Bend Device

    Thanks. Work for me (ubuntu server 16.04 LTS)
    -Indonesian Linux-

  • Nathan Jackson

    You fixed VMware’s network problems for me you glorious, glorious person.
    I was bumping into an issue where ‘apt-get’ wasn’t functioning during the install of a virtual machine or after.
    The advice they kept giving on other forums was to use ‘apt-get update’. That doesn’t help if you can’t use the internet at all.
    For others looking- I am currently using that ‘NAT’ adapter because bridged stopped functioning for no apparent reason. This resolved it for me, I recommend you try it.

    For people searching I’ll leave a few of my own personal google queries regarding the issue in hope I can get them to come here.
    “Temporary failure resolving” “archive.ubuntu” “security.ubuntu”
    “apt-get cannot connect”

  • Matt

    Thanks 😀

  • Dmitri

    Thank you very much! Worked here!

  • Scott D'Angelo

    I have DHCP, and still had to change /etc/network/interfaces
    From:
    # The primary network interface
    auto ens3
    iface ens3 inet dhcp

    To:

    # The primary network interface
    auto eth0
    iface eth0 inet dhcp

  • Opa

    Worked for me too. Thanks for the help and the great instructions!

  • Sven

    Thanks! It my case it solved an issue where I lost network after upgrading. It turns out that /etc/network/interface still had ‘eth0’ in it, while the upgrade process did indeed rename the interface to ens33

  • John

    Worked for me! thanks

  • Antonio

    Thanks! 🙂

  • Geoff

    Worked for me! Thanks. Just needed to add the GRUB_CMDLINE_LINUX=”net.ifnames=0 biosdevname=0″ and reboot and all working again.

  • Ranjeet Badhe

    Perfectly working after the changes prescribed. Thank you for the solution. Appreciate it.

  • Gene

    Very helpful! Thank you so much for taking the time to write this up – much obliged.

  • fayyaz Ur rehman

    Thank you. This is exactly what was needed.

  • Richard Gabriel

    Great, thank you very much!
    BTW, does anybody know what’s the reason to use such cryptic names for interfaces? I absolutely don’t catch that…

    • Oscar So

      Related to “Predictable-Network-Interface-Names from systemd/udev”

  • Simon de Winter

    Thank you! This solved another problem for me! I set up a static ip and my connection wouldn’t be automatically connected. (Always had to be manually turned on) This was part of the solution for me 😀

  • Gustavo Kotelchuk

    Hi! What do I need to do in order to get the eth0 interface automatically connected on startup?

    • ITzGeek Web

      Use the below line in the config file.
      auto eth0

      • Gustavo Kotelchuk

        Thank you! That was the solution. Everything is working fine now.

  • lara

    Thank’s it also worked for me. But now I can’t connect to the internet. Can someone help?

    • ITzGeek Web

      Hi Lara,

      make sure you ethernet is up and able to ping to default gateway.
      check the DNS resolution.

  • Michael Miller

    THANK YOU. This is what resolved it for me after a PXE installation of Linux Mint 18.1 x64 Mate. Installation over the network I’m sure wrecked the eth0 as being available since it was in use during install, and pushed the stupid predictable naming convention on me that Ubuntu devs thought was pretty clever.

  • José M. Manzaneque

    THANKS!

  • TheFlipside

    Thank you so much for the first part with the network aliases, annoyed me so much

  • Lorenzo GuruDj Golinelli

    Thank you, but my “ens5” still in it…
    where can i be wrong?

    • Lorenzo GuruDj Golinelli

      My fault… mispelled

      net.ifnames=0 biosdevname=0

      with

      net.iframes=0 biosdevname=0

      ….

  • paul

    How do I go back to the default name?
    I changed all of the things back to enp3s0 but it does not show when i type ifconfig

    • ITzGeek Web

      Please use the dmesg | grep -i net

      To see whether the kernel is trying to change the network card name or not

  • TomCat

    Awesome !

  • Jonny

    What if the line in question reads GRUB_CMDLINE_LINUX=”find_preseed=/preseed.cfg nopromt”
    Do i fully replace it or add it in?

    • ITzGeek Web

      Hello,

      Doesn’t matter. You can add “net.ifnames=0 biosdevname=0” addition to the existing.

  • 2bears

    Great instruction. follow steps, it really resolve my vm guest ubuntu network name issue.

    Thanks a lot.

  • Jayesh Wadhwani

    Worked perfectly. Saved me a lot of time. Thanks!