Detailed explanation of nmcli commands

nmcli (Network Manager Command Line Interface) is a command-line tool for managing and configuring the network configuration of the Network Manager service. It can help you manage network settings in the command line interface, such as viewing network connection details, creating and deleting network connections, starting and stopping network connections, viewing network device information, etc.

It is a powerful tool that can easily manage network connections, such as setting static IP addresses, setting DNS servers, enabling and disabling network devices, viewing current network status, etc.

nmcliIt can be found in most Linux distributions, and it is more flexible and convenient to use than the graphical interface, especially in the server environment, it nmcliis an indispensable tool.

Here are some examples of commonly used commands:

nmcli connection up ens160 //Enable the network card

nmcli connection down ens160 //Turn off the network card

service NetworkManager restart //restart the network

nmcli connection delete //delete network connection

nmcli device status //Display all device status

nmcli device status //View network interface details

nmcli connection reload // modify the configuration file to take effect immediately

route -n //View routing

nmcli connection add type ethernet con-name eth0 ifname eno160 //Add a network card connection

nmcli connection modify eth0 +ipv4.addresses 192.168.0.58/24 //Add an IP/subnet mask to eth0

nmcli connection modify eth0 -ipv4.addresses 192.168.0.58/24 //Delete the ip/subnet mask of eth0

nmcli connection modify eth0 ipv4.method manual //Set the IP acquisition method to manual (BOOTPROTO=static/none)

hostnamectl set-hoistname blu.net0.example.com //Set a fixed hostname

nmcli connection show //Find out the connection name corresponding to the network card

nmcli connection modify "network card name" connection.autoconnect yes //configure address, set auto-start

nmcli connection up "network card name" //Activate connection

nmcli connection show //Display network connection details

Guess you like

Origin blog.csdn.net/anluo233/article/details/129005472