List of content you will read in this article:
It is possible to fix temporary issues on specific operating systems, such as Linux, by restarting the network services. Multiple methods are available for restarting network services, including network service restart, network utility, etc. If you cannot make a secure connection with your CentOS system, you should know that a quick restart can solve many issues. Various commands are available for restarting the network on CentOS. But, as a root user, you must execute the commands using the 'su' or ‘sudo’ commands. As CentOS is one of the most commonly used and popular distributions of Linux, we'll review methods of restarting the network service on CentOS. Let's start.
How to Restart Network Services on CentOS
To restart network services, you can choose one of the methods we identified in this tutorial. These methods are listed below.
Method 1: The “nmcli” command
The ‘nmcli’ command line is offered for network status monitoring and manager access. To restart the network service on CentOS, perform the following instructions.
Step 1: First, click the ‘Activities’ tab to open it. Then, a search bar appears on the screen.
Step 2: In the search bar, search for Terminal and open it.
(Note: you can also open Terminal on your CentOS system using the ‘Ctrl+Alt+T’ keyboard shortcut.)
Step 3: After the terminal is shown, run the following command to turn off the network service:
$ sudo nmcli networking off
After running the ‘nmcli’ command, the networking service will quickly turn off, and you'll have control of the Terminal without any output.
Step 4: Now, to restart network services on CentOS, you must turn the networking service on again. To do this, run the following command in the Terminal:
$ sudo nmcli networking on
Now, the network service will start, and you'll have control of the Terminal again while no output is displayed.
You have successfully restarted the networking service on CentOS using the ‘nmcli’ command by turning off the networking service and turning it on again.
Method 2: The network manager utility
What is the network manager's utility? It's network management software that makes computer networks easier to use. You can use this software utility to restart the network on CentOS. The following steps will show you how to do that:
Step 1: Open the terminal using the ‘Ctrl+Alt+T’ keyboard shortcut or search for the word ‘terminal’ in the search box.
Step 2: Run the following command in the Terminal:
$ sudo systemctl start NetworkManager.service
Now your system will start the networking system quickly, and you'll have control of the Terminal without any output again.
Step 3: In this step, run the command below in the Terminal to stop the networking service:
$ sudo systemctl stop NetworkManager.service
Again, the network service of your system will stop immediately, control of the Terminal will be given to you, and no output will be displayed.
Step 4: The following command will help you to restart the networking service using the Network Manager utility:
$ sudo systemctl restart NetworkManager.service
The networking service will restart, and you'll regain control of the Terminal.
Do you want to verify whether your networking service has restarted or not? Run this command in Terminal:
$ sudo systemctl status NetworkManager.service
"active (running)” will appear on your screen if the network manager utility restarted your networking service successfully. So, check it after you run the command shown above.
Method 3: The systemctl command
To configure your network settings, the ‘nmcli’ command can help. You can use the ‘systemctl’ command to restart the network manager service after the network configuration is done.
# systemctl restart NetworkManager
Your network should be updated due to this command, although this command will not affect the interface configuration if NetworkManager does not manage your network.
Method 4: ifup and ifdown commands
If you're using SSH connections, use the 'ifup' and 'ifdown' commands with caution because these two commands can destroy the active SSH interface and lock you out of the system. Connecting to your server via the console can recover network access by running this command.
You can use these two commands on CentOS with or without the network manager.
Unlike older releases where the ifup and ifdown commands were part of the initscripts rpm, CentOS 8 includes both commands as part of NetworkManager.
# rpm -qf 'which ifup'
It's possible to use the ifup and ifdown commands to refresh your network configuration. For instance, you made some changes to eth1; bringing down the interface and bringing it up will refresh the changes you've made.
# ifdown eth1 && ifup eth1
In this format, the command must be executed since executing separately will result in the server becoming unreachable.
It will update the network configuration of your system.
To use the ifup and ifdown instructions, install network scripts if NetworkManager doesn't manage your network interface. To install it, use the following command:
# dnf -y install network-scripts
Now you can check the rpm ownership for ifup using the following command:
# rpm -qf 'which ifup'
In this step, ifup is part of NetworkManager and network-scripts rpm, and you can use the following command
# ifdown eth1 && ifup eth1
Some WARN syntaxes will be shown for ifup and ifdown actions like this:
WARN : [ifdown] You are using 'ifdown' script provided by 'network-scripts', which is now deprecated.
WARN : [ifdown] 'network-scripts' will be removed in one of the next major releases of RHEL.
WARN : [ifdown] It is advised to switch to 'NetworkManager' instead - it provides 'ifup/ifdown' scripts as well.
When you use ifup or ifdown without NetworkManager, it throws WARNINGs because network-scripts only support fallback behaviour.
Method 5: nmtui command
If you can't use the nmcli command and are uncomfortable with it, the ‘nmtui’ command is available for you to manage your network. Deactivating and activating your network interface is possible by entering the nmtui command in the Terminal as a root user:
Now, a window will appear on your screen. To update the network configuration, select "Activate a Connection".
You can deactivate and reactivate an interface by selecting.
Note: Your SSH connection will be lost if you deactivate an active interface. It is necessary to use nmtui from the graphical console if you intend to restart networking for your primary interface. This is regardless of whether you are connected to the network via SSH.
You can close the nmtui session if your interface is active.
CentOS provides the command “restart network” to restart individual network cards. This tutorial covers how to restart network services with different methods and examples for all CentOS distributions. "Restart network" in CentOS has a proper uncut concept, explanation, example, and alternative commands. You can expect network-scripts support to drop shortly, so you should start switching to NetworkManager. By default, we use the systemctl command to restart the network automatically. This is because it's required by request. Additionally, we need to learn the other restart methods in place of systemctl.
Let us conclude by wishing you the best of luck in restarting the CentOS Linux network.
People also read: