Software & AppsOperating SystemLinux

How To Fix Network Interface Down Issue on Ubuntu Server 22.04

Ubuntu 13

In this article, we will go through the process of fixing a common issue faced by Ubuntu Server 22.04 users – the network interface going down. This can be a frustrating problem, especially when the server needs to be constantly connected to the network. We will cover two main solutions to this problem: fixing the .yaml file and creating a systemd unit file.

Quick Answer

To fix the network interface down issue on Ubuntu Server 22.04, you can try two solutions. First, check and correct any errors in the .yaml configuration file located in /etc/netplan/. Save the changes and apply them using the command sudo netplan apply. If that doesn’t work, you can create a systemd unit file in the /etc/systemd/system/ directory to bring up the network interface during boot. After creating the file, enable the service using sudo systemctl enable manual-iface.service.

Solution 1: Fixing the .yaml file

In Ubuntu Server 22.04, network interfaces are configured using the Netplan tool, which uses .yaml files for configuration. If your network interface is going down, it might be due to an error in your .yaml configuration file.

The first step is to locate and open your .yaml file. The file is usually located in the /etc/netplan/ directory. You can use a text editor like nano to open the file:

sudo nano /etc/netplan/01-netcfg.yaml

In this command, sudo is used to run the command with root privileges, nano is the text editor, and /etc/netplan/01-netcfg.yaml is the path to the .yaml file.

Once the file is open, you should see something similar to this:

network:
 version: 2
 renderer: networkd
 ethernets:
 enp0s25:
 dhcp4: true
 enp6s0f1:
 dhcp4: true
 usb0:
 dhcp4: false

In this configuration, enp0s25, enp6s0f1, and usb0 are the names of the network interfaces. dhcp4 is set to true for enp0s25 and enp6s0f1, which means they will automatically obtain an IP address from the DHCP server. usb0 is set to false, which means it won’t obtain an IP address automatically.

If your network interface is going down, check if there’s a typo in the interface name or if dhcp4 is set to false. Correct any errors, save the changes, and apply them by running:

sudo netplan apply

This command applies the changes made to the .yaml file. If the configuration is correct, the network interface should stay up after a reboot.

Solution 2: Creating a systemd unit file

If the first solution doesn’t work, you can create a systemd unit file to bring up the network interface during boot. Systemd is a system and service manager for Linux, and a unit file is a configuration file for a service.

Here’s how to create a systemd unit file:

  1. Open a new file in the /etc/systemd/system/ directory using a text editor:
sudo nano /etc/systemd/system/manual-iface.service
  1. Add the following lines to the file:
[Unit]
Description=Service to bring up/down unconfigured nic enp6s0f1
After=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/ip link set enp6s0f1 up
ExecStop=/sbin/ip link set enp6s0f1 down

[Install]
WantedBy=multi-user.target

In this configuration, enp6s0f1 is the name of the network interface. ExecStart and ExecStop are commands that are executed when the service is started and stopped, respectively. ExecStart brings up the network interface, and ExecStop brings it down.

  1. Save the file and exit the editor.
  2. Enable the service to start at boot by running:
sudo systemctl enable manual-iface.service

This command enables the manual-iface.service service to start at boot.

After a reboot, the systemd service should bring up the network interface automatically.

Conclusion

In this article, we covered two solutions to the network interface going down issue on Ubuntu Server 22.04. The first solution is to fix the .yaml configuration file, and the second solution is to create a systemd unit file. Both solutions should help keep your network interface up after a reboot. If you’re still facing issues, you might want to check the Ubuntu Server documentation or seek help from the Ubuntu community.

How can I check if my network interface is down?

You can check the status of your network interface by running the command ip link show. If the interface is down, it will show as "DOWN" in the output.

Can I have multiple `.yaml` files for network configuration?

Yes, you can have multiple .yaml files for network configuration in Ubuntu Server 22.04. Each file should be named in the format XX-configname.yaml, where XX is a number indicating the order in which the files will be processed. For example, 01-netcfg.yaml, 02-custom.yaml, etc.

How can I check the status of a systemd service?

You can check the status of a systemd service by running the command systemctl status [service-name]. This will display information about the service, including whether it is running, enabled, or any errors that may have occurred.

What should I do if the network interface is still not working after applying the solutions?

If the network interface is still not working after applying the solutions, you can try restarting the server. If the issue persists, you may need to check the hardware connections or seek further assistance from the Ubuntu community or a network administrator.

Leave a Comment

Your email address will not be published. Required fields are marked *