Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use nmcli tools to manage Network in CentOS 7

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Nmcli is a command-line tool for controlling NetworkManager and reporting network status. Nmcli is used to create, display, edit, delete, activate, and deactivate network connections, and to control and display the status of network devices. Basic usage nmcli [OPTIONS...] {help | general | networking | radio | connection | device | agent | monitor} [COMMAND] [ARGUMENTS...]

You can use the TAB key to complete the command, forget the syntax, and press TAB to see the available options. If pressing the TAB key does not respond, maybe bash-completion is not installed

# install bash-completion [root@localhost ~] # yum-y install bash-completion# exit and log in to [root@localhost ~] # exit

Tab to see the available options

View the status of NetworkManager:

[root@localhost ~] # nmcli general status STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN connected full enabled enabled

List connection profile information:

[root@localhost ~] # nmcli connection show NAME UUID TYPE DEVICE enp0s3 5005942f-a7fd-4e55-b8e7-77928d8da72d ethernet enp0s3

Displays the status of the network card:

[root@localhost] # nmcli device status DEVICE TYPE STATE CONNECTION enp0s3 ethernet connected enp0s3 lo loopback unmanaged--

You can use the nmcli command line to start or stop the network card, which is the equivalent of the ifup/ifdown command.

Stop the network card: [root@localhost ~] # nmcli device disconnect enp0s3

Open the network card: [root@localhost ~] # nmcli device connect enp0s3

Modify the network card information from the original dhcp automatic acquisition to manually add the address: [root@localhost ~] # nmcli connection modify enp0s3 ipv4.method manual ipv4.addresses 192.168.0.110and24 ipv4.gateway 192.168.0.1 ipv4.dns 202.102.128.68 [root@localhost ~] # nmcli connection up enp0s3

View the Nic configuration file information and add additional IP [root@localhost ~] # nmcli connection modify enp0s3 + ipv4.addresses 192.168.0.108Accord 2 "enable configuration file [root@localhost ~] # nmcli connection up enp0s3# View ip address [root@localhost ~] # ip add show enp0s32: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:7b:d3:32 brd ff:ff:ff:ff:ff:ff inet 192.168.0.107 brd 24 brd 192.168.0.255 scope global noprefixroute enp0s3 valid_lft forever preferred_lft forever inet 192.168.0.108Accord 24 brd 192.168.0.255 scope global secondary noprefixroute enp0s3 valid_lft forever preferred_lft forever inet6 fe80::d4d9:9043:1056:9e1a/64 scope link noprefixroute valid_lft forever preferred_lft forever delete additional IP [root@localhost ~] # nmcli connection modify enp0s3-ipv4.addresses 192.168.0 .108 qdisc pfifo_fast state UP group default qlen 2 enables the configuration file [root@localhost ~] # nmcli connection up enp0s3# to view the ip address [root@localhost ~] # ip ad show enp0s32: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:7b:d3:32 brd ff:ff:ff:ff:ff:ff inet 192.168.0.107 Universe 24 brd 192.168.0.255 scope global noprefixroute enp0s3 valid_lft forever preferred_lft forever inet6 Fe80::d4d9:9043:1056:9e1a/64 scope link noprefixroute valid_lft forever preferred_lft forever summary

In the command line interface, it is very convenient to modify the network card information with nmcli for directly modifying the configuration file.

Original address: https://www.linuxprobe.com/centos7-nmcli-tools.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report