Methods to Restart Networking on Ubuntu Linux

Steps To Restart A Network On Ubuntu Linux

In Linux, the user has the free will of stopping, starting or restarting network services. These operations can be done using a single line command provided the user is a regular customer of our Linux friendly website. In this article, we learn various ways of restarting our network connections using the command line.

Restart Networking on Ubuntu Linux through Network Manager

As we know, the first point of contact with our system, in the context of networking, is the Network Manager. In order to restart network connections, we will restart the network manager itself.

1. Systemctl command

In Linux based systems, systemd is the service manager that is responsible for the management of various background applications, called services. In order to control these services effectively, systemd has a powerful command systemctl that has jurisdiction over these services.

Before we fiddle with any service, let us take a look at what network related services our system supports. We can fetch the list of services by:

sudo systemctl --type service
Restart Network List Services Edited 1
List of Services

We can simply restart the network connections by running:

sudo systemctl restart NetworkManager.service
Restart Network Systemctl
Restart Network using systemctl

If the system is connected through Wi-fi or Bluetooth, the icons at the top-right corner of the screen will vanish and then reappear. The reason for the said observation is quite obvious, we restarted NetworkManager on Ubuntu.

Stop the network using systemctl:

In addition to restarting, we can stop the functioning of any service by:

sudo systemctl stop NetworkManager.service
Restart Network Stop Systemctl Edited
Stop Network Manager using systemctl

The browsers and other network-related applications will stop functioning as the network manager has been stopped. This trick can be used to isolate a system from networks. Opposite to the above command, in order to start the network, we will enter:

sudo systemctl start NetworkManager.service

To learn more about listing services in Linux, visit here.


2. Service command

Similar to the systemctl command, service is a compact command with a complete focus on system services. To list the services using service command, we can run:

sudo service --status-all
Restart Network List Service Edited
List of services

The '[ + ]' symbol before the service name means that the service is up and running. To restart the network using the service command, we run:

sudo service network-manager restart
Restart Network Using Service
Restart Network using service command

The connections established will be restarted after the command is run.


3. Nmcli command

Even more compact than service command, nmcli has all its attention over Network Management on Ubuntu Linux. nmcli is an acronym for “Network Manager Command-Line Interface”. We need to simply run:

sudo nmcli networking off
sudo nmcli networking on

The first command deactivates all the interfaces under the jurisdiction of the Network Manager. The second line, reverses the effect of the first line, thereby restarting the network on Linux.

Restart Network Nmcli
Restart network using nmcli

The command 'nmcli device status' presents the current status of each network interface. It has been added in the image to display the condition of each network interface while restarting network using nmcli.

It must be duly noted that in this method, the Network Manager is not disabled, it is the interfaces that are deactivated using the Network Manager.


Restarting the network through Network Interfaces

The Network Manager controls the Network Interfaces in a Linux system. There are few commands that work with the network interfaces for a quick network restart.

1. Ifup-Ifdown commands

As the name suggests, these two commands can bring up or take down any or all network interfaces in Linux. To do the required, we run:

sudo ifdown -a
sudo ifup -a

The first line takes down all network interfaces on the system. The system will keep on displaying connection with the internet, but the network interfaces will stop receiving or sending data packets. It is a very sleek way of disabling networks in a system.

The second as usual brings up all the network interfaces, thereby restarting the network on Linux.

Restart Network Ifdown Ifup
Restart network using ifdown and ifup

The '-a' option specifies the command to take down or bring up all network interfaces. In case, the user wants to restart only a specific interface, then it can be done by:

sudo ifdown <interface_name>
sudo ifup <interface_name>
Restart Network Restart Lo Edited
Restart ‘lo’ interface

The intermediate command displays the status of the particular network interface.


2. Ifconfig command

The effects of ifconfig command are similar to the previous method. The one drawback of ifconfig is that it can restart one interface at a time. It is done by:

sudo ifconfig <NI_Name> down
sudo ifconfig <NI_Name> up

The first command deactivates the network interface, while the following command activates it.


3. IP command

The last method for restarting a network on Ubuntu is using the ip command to shutdown specific interfaces and bring them back up. It is done by:

sudo ip link set <NI_Name> down
sudo ip link set <NI_Name> up

The functioning is similar to ifconfig command.


Conclusion

Many situations may arise where you need to restart a network on Ubuntu. The easiest and the most effective way to restart the network on Linux is by using systemctl command. In addition to restarting, it has a better printing format for every service it manages.

We hope this article provided enough information to the reader on the respective topic. Feel free to comment below for suggestions or queries.