Restart Network Manager Ubuntu
Introduction to Network Manager
A network manager can be defined as a daemon that resides on libudev and other interfaces of the Linux kernel (and a set of other demons) and offers a high-level interface for network interface configuration. It is a software utility that focuses on simplifying computer network use. It is also accessible for Linux-based and Unix-like operating systems.
Working of Network Manager
Several communication protocols have been integrated to connect systems with each other, e.g., IEEE 802.3 (Ethernet), IEEE 802.11 (wireless), IEEE 802.15.1 (Bluetooth), PPPoA, PPPoE, and others. All participating computers must have compatible hardware, e.g., a wireless network card or a network card, and hardware must be accordingly configured to be able to make a connection.
Every device driver is a part of it in case of any monolithic kernel. The hardware is used (and also configured) using its device driver. The kernel presents for all device driver representations in a device file form in the case of Linux. Every device file is found inside the directory, i.e., /dev, and the device file has been named eth0, eth1, etc., for Ethernet hardware.
They are differently named: enp4s0, etc., since systemd. This abstraction is known as everything is a file concept. In user space, anything uses the hardware from its device file, configuration utility for configuring the hardware, and functions like NTP/SSH/web browser-client/etc., to receive and send network packets.
Network interface configuration without Network Manager
On all Unix-like and Linux operating systems, the newer ip and ifconfig (through the iproute2-bundle) are used for configuring IEEE 802.11 and IEEE 802.3 hardware. These utilities directly configure the kernel, and the configuration is immediately applied. The user is needed to again configure them after boot-up.
To apply the similar static configuration after all boot-ups, the PID1 programs are utilized: System V init runs binary programs and shell scripts, systemd parses its conf-files (and runs programs). For network interfaces, the boot-up configuration is saved in /etc/network/interfaces for Linux Debian distributions and its ifcfg or derivative files in /etc/sysconfig/network-scripts/ for Fedora and its derivates, and /etc/resolv.conf is used to store DNS servers.
/etc/sysconfig/network-scripts/ifcfg-* or /etc/network/interfaces can define a dhclient or static IP address to be used, and every type of VPN can also be configured. In case of configuration has to be modified, DHCP protocol can do so automatically.
Network configuration interface with Network Manager
Although the dynamic configuration has been a more basic configuration increasingly (i.e., stored in the static configuration file but bring from the host outside and potentially modified after boot), especially because we have shifted from large servers physically to more flexible hosts that might be plugged/unplugged (or shifted from a WiFi hotspot to another WiFi hotspot) at the user will. An early protocol, i.e., Bootp, was used for it.
Several Unix-like systems contain a program known as dhclient to manage the dynamic configuration. Relatively, given a simple or static dynamic configuration, static configuration changed by dhclient operates well. Although, a central manager for every network configuration detail becomes more necessary because networks and their topologies are more complex.
Network Manager contains two elements which are listed and mentioned below:
Applications can be specified as "link-aware" or to entirely substitute the given applet because the elements communicate by D-Bus. KNetworkManager is an example which is a front-end to the Network Manager integrated for SUSE Linux by Novell.
Command-line and graphical front-end interfaces
History of Network Manager
In 2004, Red Hat started the NetworkManager project with the aim of enabling the users of Linux to deal more efficiently with modern networking requirements, specifically wireless networking. Network Manager grabs an opportunistic method for network selection, trying to apply the best connection because outages appear or because the user roams among wireless networks.
It selects Ethernet connections as a replacement for "known" wireless networks, selected over wireless networks along with SSIDs to which a user has never linked. The user is asked for WPA or WEP keys as required.
This project was among the initial major Linux desktop elements to utilize HAL and D-Bus extensively. Network Manager no longer relies on HAL since June 2009, and neither does it need the D-Bus daemon to be executing for root operation since 0.9.10.
Network Manager for Administrators
Note: There is a package NetworkManager-config-server on RHEL and Fedora that installs a configuration snippet using the two options mentioned above.
Restarting Network on Ubuntu
There are many situations where we may need to restart our network on Ubuntu. It might be due to the network settings being modified. It may be because the network connection is operating weirdly. Whenever there is an issue with the system, a basic treatment is implementing a reboot. However, if it is an issue related to our network, then it is possible to only restart our network.
In this article, we will discuss how to restart the network on Ubuntu. There are many methods we can follow to reboot the network in Ubuntu. It can be directly performed from the terminal or GUI. Depending on our preference, we can follow the one that suits us.
Restart Network through the Desktop
Restart Network through GNOME Settings
Restart Network with CLI
There are many ways of taking action when operating with CLI. We can take action on any network manager service or apply other tools such as nmtui, ifup, nmcli, etc.
Restart network manager service
Restart network service with systemd
Systemd provides an array of system elements to the system. Part of it's managing the services. The old method is just a replacement for this technique. Systemd is told directly for restarting the service instead of proceeding with any hoop.
We can run the following command to do so:
Restart network with nmcli
This tool is a strong tool to manage the network connection in Linux. It is a famous one among system admins due to its ease of use.
First, we need to turn off our network connection by using the below command:
Then, turn it on again by using the following command:
Restart network with ifdown and ifup
The ifdown and ifup commands directly manage a network interface. It is one of the most common networking commands in Linux. The command, i.e., ifdown, turns off every network interface and the command, i.e., ifup, turns them on.
The ifdown and ifup commands provide the ifupdown package. It does not come with Ubuntu by default. It is directly available through the official Ubuntu repository. We can install them from there.
We can implement the network restart process once the installation process is completed.
It is a good practice to merge both commands in one line.
Restart network with nmtui
It is yet another tool of network management that is widely famous among system admins. It provides an interactive way of handling network connections that is the same as the GUI method, unlike many CLI tools.
By default, it comes with the 20.04 version of Ubuntu. We can launch the tool by using the below command:
We can utilize the arrow keys for navigating the tool. Choose the "Activate a connection" option.
We will land on the screen along with a list of every network connection. Choose the correct one and choose the "Deactivate" option.
Once deactivated, we can activate the connection.
The network is successfully restarted. We can quit the application.
Restart network with IP command
IP command is a strong way of handling the network connections in Linux. It can be used to restart the network connection. This technique is applicable to all Linux distributions.
To operate with the IP command, we need to be aware of the target network interface. We can use the below command to know the network interface: