Ubuntu lost network after kernel upgrade

How I fixed network problems in Ubuntu

Page content

After automatically installing a new kernel, Ubuntu 24.04 has lost the ethernet network. This frustrating issue occurred for me a second time, so I’m documenting the solution here to help others facing the same problem.

Commands to Fix Network Issues

Here are the commands that restored my network connectivity. First, check your kernel version with uname -r (it will show something like 6.14.0-37-generic), then replace the version number in the commands below:

# Check the network interfaces and IP addresses
ifconfig

# Check the kernel version
uname -r

# Update package lists and upgrade system
sudo apt update
sudo apt upgrade

# Install kernel extra modules for the version discovered above
# Replace 6.14.0-37-generic with your actual kernel version
sudo apt install linux-modules-extra-6.14.0-37-generic

# Rebuild the initramfs to include the new kernel modules
sudo update-initramfs -u

# Install recommended proprietary drivers (primarily for NVIDIA graphics)
sudo ubuntu-drivers autoinstall

# Reboot to apply changes
sudo reboot

Understanding the Problem and Solution

When Ubuntu automatically upgrades to a new kernel version (which happens during regular system updates), sometimes the network drivers aren’t properly included in the new kernel’s boot filesystem. This is particularly common with Ubuntu 24.04 after kernel upgrades, especially on systems with specific network hardware that requires additional kernel modules.

Why This Happens

  1. Kernel modules are version-specific: Each kernel version requires its own set of driver modules
  2. Initramfs may be incomplete: The initial RAM filesystem (initramfs) loaded during boot might not contain all necessary network drivers
  3. Extra modules package missing: The linux-modules-extra package for the new kernel version may not have been automatically installed

How the Solution Works

The commands above fix the issue by:

  1. Installing kernel extra modules: The linux-modules-extra-<version>-generic package contains additional kernel modules, including many network drivers that aren’t included in the base kernel package. Without these modules, your network hardware won’t be recognized.

  2. Rebuilding the initramfs: The update-initramfs -u command ensures that all necessary kernel modules (including your network drivers) are packaged into the initramfs. This is critical because the initramfs is loaded before the root filesystem is mounted, and it needs to contain drivers for essential hardware like network interfaces.

  3. Installing proprietary drivers: The ubuntu-drivers autoinstall command primarily handles graphics drivers (especially NVIDIA) and doesn’t directly fix network issues. However, if your system lost multiple drivers during the kernel upgrade, this ensures all proprietary drivers are properly installed.

  4. Rebooting: This loads the new kernel with the properly configured initramfs, restoring network connectivity.

After rebooting, your network should be restored. You can verify by running ifconfig or ip a again to see your network interfaces with assigned IP addresses. If you need to check your Ubuntu version to ensure compatibility, there are several methods available.

If you’re working with a server and need to configure network settings after restoring connectivity, you might find our guide on how to change a static IP address in Ubuntu Server helpful for further network configuration.

Very Nice Borat!