Upgrading Ubuntu often causes network interfaces to rename from eth0 to predictable names like enp3s0 or en01, breaking scripts that expect the old naming convention. This mismatch between configuration files and actual hardware names results in lost internet connectivity after an upgrade to 20.04.6.
Understanding Network Interface Renaming
Ubuntu has transitioned from the traditionalethX naming scheme to a more predictable, hardware-based naming convention introduced in systemd. When you upgrade from older versions like 16.04 or 18.04 to 20.04.6, the system may detect your network card differently, assigning it a name such as en01, enp3s0, or eno1. If your network configuration files, such as those in /etc/network/interfaces or Netplan YAML files, still reference the old eth0 or eth1 names, the operating system will fail to bring up the interface correctly.
This issue is particularly common when using virtual machines or specific hardware where the driver behavior changes between kernel versions. The lshw command can help identify the current hardware details, but the key is to align your software configuration with the new hardware identity. For users experiencing similar upgrade hurdles, reviewing the broader context of installation errors can be helpful, as seen in Stuck During Ubuntu Upgrade? Try These Troubleshooting Steps!.
Diagnosing the Current Interface Names
Before making any changes, you must confirm the actual names assigned to your network interfaces by the kernel. Open a terminal and run the following command:ip addr show
Look for lines starting with link/ether or link/loopback. You will likely see interfaces named something like enp0s3, en01, or wlan0. Note these exact names. Do not assume they are still eth0. If you have multiple interfaces, ensure you identify the one connected to your Ethernet cable or Wi-Fi adapter. In some cases, especially with Hyper-V or other virtualization platforms, you might see unexpected secondary interfaces, which is discussed further in Understanding Two Network Interfaces in Ubuntu 22.04 with Hyper-V Virtual Machines.
Additionally, check the status of the networking service:
systemctl status networking
If the service reports failures or inactive states for the expected interface, it confirms that the configuration does not match the hardware reality.
Fixing Configuration Files
The solution depends on whether you are using the legacyifupdown package or the modern Netplan system. Most Ubuntu 20.04 installations use Netplan.
For Netplan Users:
Netplan configuration files are located in /etc/netplan/ and typically end with a .yaml extension. Open the file using a text editor with sudo privileges:
sudo nano /etc/netplan/01-netcfg.yaml
(Note: The filename may vary, e.g., 50-cloud-init.yaml). Inside this file, look for the interfaces key. Replace any instance of eth0 or eth1 with the correct name identified in the previous step (e.g., en01). Ensure the indentation is correct, as YAML is sensitive to whitespace. Save the file and apply the changes:
sudo netplan apply
For Legacy ifupdown Users:
If you are still using the older method, edit /etc/network/interfaces:
sudo nano /etc/network/interfaces
Find the line defining your interface, such as auto eth0 or iface eth0 inet dhcp, and change eth0 to the new name. Then restart the networking service:
sudo systemctl restart networking
Restoring Internet Connectivity
After updating the configuration files, verify that the interface is now active. Runip addr show again and check if the new interface has an IP address assigned. If you are using DHCP, the system should automatically request an address. If you are using static IPs, ensure the static values in your config file match your network's requirements.
If the connection still fails, try disabling and re-enabling the interface:
sudo ip link set en01 down
sudo ip link set en01 up
Replace en01 with your actual interface name. This forces the kernel to re-initialize the driver and apply the new configuration. If you recently upgraded and suspect kernel-related issues, checking your installed kernels is also advisable, as described in Upgrading Ubuntu: Checking Installed Kernels in the Boot Partition.
In rare cases, residual configurations from previous upgrades may cause conflicts. A clean reboot often clears temporary states and ensures all services start with the new configuration. If problems persist, consider reverting to a known good state or performing a fresh installation if data backup allows.
Frequently Asked Questions
Why did my interface name change from eth0?
Ubuntu switched to predictable network interface names to avoid conflicts and provide consistent naming based on hardware topology. This change was implemented to replace the arbitraryethX assignments that could vary between boots or hardware additions.
How do I find my new interface name quickly?
Runip -br addr in the terminal. This command provides a brief, readable list of all network interfaces along with their current status and IP addresses, making it easy to spot the active connection.
Can I revert to eth0 naming?
Yes, you can add the kernel parameternet.ifnames=0 biosdevname=0 to your GRUB configuration. However, this is generally discouraged because it may lead to naming inconsistencies in complex hardware setups or future upgrades.
What if netplan apply gives an error?
Check the syntax of your YAML file carefully. Indentation errors are the most common cause. Useyamllint or online validators to check the file structure. Also, ensure there are no trailing spaces or tabs that YAML parsers might misinterpret.
Does this issue affect Wi-Fi connections too?
Yes, Wi-Fi interfaces also follow the new naming convention, typically starting withwl (e.g., wlp2s0). If your Wi-Fi stops working after an upgrade, update the corresponding interface name in your Netplan or network manager settings.