Javatpoint Logo
Javatpoint Logo

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

  • Network Manager is accessible by dbus.
  • /etc/NetworkManager/NetworkManager.conf is used to store configuration.

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.

Software Architecture:

Network Manager contains two elements which are listed and mentioned below:

  • Network Manager daemon: It is a real software which handles report and connection network modifications.
  • Many graphical front-ends for different graphical desktop environments, like Cinnamon, KDE Plasma Workspaces, GNOME Panel, GNOME Shell, etc.
    Both elements are predetermined by the developers to be portable reasonably, and the applet is present for desktop environments which operate the System Tray Protocol, i.e.,org, including Xfce, Enlightenment (software), KDE Plasma Workspaces, and GNOME.

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

  • nm-applet: For Network Manager, it is a GNOME applet.
  • nmcli: It is a built-in command-line interface of Network Manager added in 2010. It also permits the display of Network Manager monitor connections, manages devices and connections, and current status.
  • nmtui: It is a text-based user interface (built-in) added in 2010. Relatively, it is more common than nmcli, which only permits users to edit/add a connection, enable a connection, and set the system hostname.
  • cnetworkmanager: For NetworkManager, it is a command line interface.
  • Mobile broadband configuration assistant: In April 2008, Antti Kaijanmaki announced a mobile broadband configuration assistant development for NetworkManager; it became present in the 0.7.0 version of NetworkManager. Together with the mobile-broadband-provider-info package, the connection is configured easily.

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

  • Architecture
    A network manager is, by default, developed to be fully automatic. It handles the main network connections and other network interfaces, such as Mobile Broadband devices, Wi-Fi, and Ethernet. Network manager service should be started to use it.
    Starting up Network Manager relies on the distribution we are using, but the network manager transmits with systemd service files to do it for almost all distributions. Automatically, the network manager will begin other services because it needs them (pppd for mobile broadband and wpa_supplicant for 802.1x and WPA connections).
  • Security
    The network manager supports almost all network security protocols and methods, WPA/WPA2/WPA3 (Enterprise and Personal), wired 802.1x, VPNs, and MACsec.
    The network manager saves network secrets (login information and encryption keys) with secure storage, either in the keyring of the user (for user-specific connections) or secured by general system administrator permissions (such as root) for system-wide connections. Several network tasks can be locked down with a polkit for finer grain control on network connections.
  • Configuration files
    The configuration file for the network manager is NetworkManager.conf. It is used for setting up several aspects of the behavior of the Network Manager.
    If a NetworkManager.conf default is given by the packages of our distribution, we should not modify it since our modifications may get overwritten via package updates. Rather, we can add extra files with the extension, i.e., .conf, to the directory, i.e., /etc/NetworkManager/conf.d. They will read in sequence with later files overriding previous ones.
    Packages may install configuration snippets to the /usr/lib/NetworkManager/conf.d directory. This directory is first parsed even before NetworkManager.conf. Also, scripts can put per-boot configuration into the /run/NetworkManager.conf.d directory. This directory is second parsed before NetworkManager.conf.
  • VPN
    The network manager contains pluggable support for VPN applications, including Cisco-ompatible VPNs, openvpn, and PPTP (Point-to-Point Tunneling Protocol). Support for other clients of VPN is welcomed.
    We need to simply download the Network Manager VPN plug our site uses and pre-load the machines of the user with the settings of VPN. The user will be promoted for their passwords the initial time they connect.
  • Server-like behavior
    The network manager automatically establishes a new in-memory connection for all Ethernet devices that do not have other candidate connections on disk by default. These newer connections have the name, such as "Wired connection 1", "Wired connection 2", and so on; they have IPv6 and DHCPv4 autoconfiguration enabled.
    Usually, this behavior is not fascinating on servers, where every interface should be explicitly configured. To disable the establishment of such automatic connections, we can add no-auto-default=* to the configuration section, i.e., [main].
    The network manager also needs a carrier on an interface before any connection can be enabled on it. If there is any service that requires binding to the interface address during boot, it might fail when the interface contains no carrier. The solution is deactivating carrier detection with the ignore-carrier=* configuration option in the section, i.e., [main].

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

  • We need to press the top-right icon of the network on the screen.
    Restart Network Manager Ubuntu
  • Choose the network connection and click on the "Turn Off" It will turn off the network connection.
  • To again enable it, proceed with a similar process. There will be a different "Connect" option this time. Press the "Connect" option to re-create the network connection.
    Restart Network Manager Ubuntu

Restart Network through GNOME Settings

  • We can also do it directly through the GNOME "Settings".
    Restart Network Manager Ubuntu
  • Choose the "Network" option from the left-side panel.
    Restart Network Manager Ubuntu

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

  • It is one of the easiest ways of rebooting the network service. It is equivalent to the graphical technique demonstrated above.
  • We need to open the terminal window and execute the below command:

Restart Network Manager Ubuntu

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 Manager Ubuntu

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:

Restart Network Manager Ubuntu

Then, turn it on again by using the following command:

Restart Network Manager Ubuntu

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.

Restart Network Manager Ubuntu

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.

Restart Network Manager Ubuntu

We will land on the screen along with a list of every network connection. Choose the correct one and choose the "Deactivate" option.

Restart Network Manager Ubuntu

Once deactivated, we can activate the connection.

Restart Network Manager Ubuntu

The network is successfully restarted. We can quit the application.

Restart Network Manager Ubuntu

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:

Restart Network Manager Ubuntu

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA