CentOS restart network | How CentOS restart network work with example?

CentOS restart networkCentOS restart network

Introduction to CentOS restart network

In the Linux environment, the network service is very important in terms of application or job level, intra N/W communication, internet, etc. The network services will play a significant role in terms of network security, data communication over the network, etc. In the CentOS distribution, once we will do any changes in the network level or network configuration level. Then we need to restart the network. Unless and until we haven’t restarted the network services, it will not deploy the new network configuration on the system or environment level. There are multiple ways that we can achieve the network restart activity like network utility, network service restart, etc. In this topic, we are going to learn about the CentOS restart network.

Syntax of CentOS restart network

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

systemctl / nmcli [ OPTION ] [ NETWOKR | NETWORK SERVICES ]

1. systemctl / nmli: The systemctl and nmcli both are different utilities. The systemctl is used to restart the complete network service. The nmcli is a network command-line utility. Both the method will do the network restart, but the working method is different. The nmcli is nothing but a command-line utility. It will help to get the network details from the CentOS Environment. We can use the nmcli keyword in the syntax or command. It will accept arguments like different OPTIONS, NETWORK or NETWORK SERVICES, etc. The netstat command will help to restart the network in the CentOS environment.

2. OPTIONS: We can provide the different flags as the option that is compatible with the systemctl or nmcli command.

3. NETWOKR | NETWORK SERVICES: These are the keywords that we can use in the systemctl or nmcli command.

How CentOS restart network Works

The network restart activity will be performing if we want to apply the new network configuration. Below are the lists of option that are compatible with the “nmcli” command.

  1. a | –ask: When are we using this option, then the nmcli will stop. It will ask for any missing required arguments. IF we are using the non-interactive task, then it is highly recommended to do not to use this option like running the scripts or automated jobs. When we need a password to prompt on the user screen, then only we need to use this option.
  2. -c | –colors {yes | no | auto}: This option will help to control the color output (like for using terminal escape sequences). Suppose we will set it to yes then enable colors. If we will set no, then it will be disabled. We have the auto option also then only produces colors when standard output only on the terminal screen. But the default value is auto.
  3. –complete-args: If we are using this option, then instead of conducting the desired action, the nmcli will list possible completions for the last argument. On the shell level, the option will use to implement argument completion. If the status is an exit, then it will indicate success status or return a code 65. It will indicate the last argument in a file name. The network managers will ship with command completion support for GNU Bash.
  4. -e | –escape {yes | no}: In the tabular mode, whether the escape: and \ characters. The escape character is \. If the option is omitted, then the default is yes.
  5. -f | –fields {field1,field2… | all | common}: This option will help you to use to specify what fields (majorly the column names) should be printed. The Valid field names may differ for specific commands. The list available fields by providing an invalid value to the –fields option. All is used to print all the valid field values of the command. If it is omitted, then the default is common.
  6. -g | –get-values {field1,field2… | all | common}: If we want to print the values from the specific fields, then we can use this option. Basically, it is a shortcut for the –mode tabular and –terse –fields. It is a convenient way to retrieve values for particular fields. Without the header option, it will print the values one per line. Instead of the field, if the section is specified, then the section name will be printed followed by colon-separated values of the fields belonging to that section option. It will be on the same line.
  7. -h | –help: It will print the help of the information. It will exit automatically.
  8. -p | –pretty: If we will use this option, then the Output is pretty. The nmcli to produce easily readable outputs for humans like headers are printed properly; the values are aligned, etc.
  9. -s | –show-secrets: With the help of this option, the nmcli will display passwords and secrets. It will be present in an output of an operation.

Examples to understand CentOS restart network.

Here are the following examples mention below

CentOS restart network: With systemctl

In the CentOS environment, we have multiple ways to restart the network. But as per the requirement, we need to choose the convenient method. Here, we are using the systemctl method to restart the network.

Command :

systemctl restart network

Explanation :

As per the above command, we are restarting the network service from the CentOS environment. We are using the restart keyword with the systemctl command.

Output :

CentOS restart network output 1CentOS restart network output 1

CentOS restart network: With NMCLI

The nmcli is a command utility to manage the network. We can start and stop the network also.

Command:

nmcli networking off
nmcli networking on

Explanation :

As per the above command, we are using the “nmcli” utility to start and stop the network.

Note: when we run the “nmcli networking off” command, all the network communication will stop.

Output :

CentOS restart network output 2.1CentOS restart network output 2.1

Screenshot 1 (a)

CentOS restart network output 2.2CentOS restart network output 2.2

Screenshot 1 (b)

Conclusion

We have seen the uncut concept of the “CentOS restart network” with the proper example, explanation, and command with different outputs. By default, we are using the systemctl command to restart the network. As per the requirement, we need to use the restart method.

Recommended Articles

This is a guide to the CentOS restart network. Here we discuss the uncut concept of the “CentOS restart network” with the proper example, explanation, and command with different outputs. You may also have a look at the following articles to learn more –

0

Shares

Share

Primary Sidebar