11.12.2024

How to Restart Network in Ubuntu

First you need to find out which network manager the system uses.

In this example we’re running Ubuntu 18.04 which uses Netplan to configure networks.

What is Netplan used for?

Netplan is a new command-line network configuration utility introduced in Ubuntu 17.10 to manage and configure network settings easily in Ubuntu systems. It allows you to configure a network interface using YAML abstraction. It works in conjunction with the NetworkManager and systemd-networkd networking daemons (referred to as renderers, you can choose which one of these to use) as interfaces to the kernel.

It reads network configuration described in /etc/netplan/*.yaml and you can store configurations for all your network interfaces in these files.

So the first thing to do is to check what configuration files do we have in /etc/netplan/
We can check this out by using the command:

ls /etc/netplan/

Here we can see configuration file called “50-cloud-init.yaml”.

Now we need to read it to see configuration:

cat /etc/netplan/50-cloud-init.yaml

In the Renderer we can see the “NetworkManager” – that’s our active network manager.

To restart it simply run:

sudo service network-manager restart

And then to see it’s status run:

sudo service network-manager status

As we can see it’s active and running.

If you see “networkd” in the Renderer in the netplan configuration file you need to restart it with the command:

sudo systemctl restart systemd-networkd

And then to see it’s status run:

sudo systemctl status systemd-networkd

That’s all, network is restarted.