centos7nmcli网络管理

环境:centos7、启动了NetworkManager服务

1、添加网络配置ip

 [root@localhost ~]# nmcli connection add type ethernet con-name ens30 ifname eno16780032 autoconnect yes ipv4.method manual ipv4.addresses '192.168.1.10/24' ipv4.gateway '192.168.1.1' ipv4.dns '192.168.1.1'
Connection 'ens30' (2ba67a33-eaaa-471b-956e-386d456a66f3) successfully added.

2、下面为一些常用命令

[root@localhost ~]# nmcli device   #查看设备
DEVICE   TYPE      STATE      CONNECTION 
docker0  bridge    connected  docker0    
ens192   ethernet  connected  ens192  
[root@localhost ~]# nmcli connection  #查看现有链接
NAME     UUID                                  TYPE            DEVICE  
docker0  16e82cdf-ef66-49c7-bc9e-8fbd23cbc358  bridge          docker0 
ens192   17a9f6e9-b804-4e7f-b205-9de482cf1c2a  802-3-ethernet  ens192 

[root@localhost ~]# nmcli connection show ens192  #显示ens192的配置明细
connection.id: ens192
connection.uuid: 17a9f6e9-b804-4e7f-b205-9de482cf1c2a
connection.stable-id: --
connection.interface-name: ens192
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.autoconnect-priority: 0
connection.timestamp: 1594124039
connection.read-only: no
。。。。。。。

[root@localhost ~]# nmcli connection reload    #重载配置

[root@localhost ~]# nmcli connection up ens192  #启用配置

[root@localhost ~]# nmcli connection down ens192 #停用配置

[root@localhost ~]# nmcli connection delete ens30  #删除配置
Connection 'ens30' (2ba67a33-eaaa-471b-956e-386d456a66f3) successfully deleted.

做一个决定,并不难,难的是付诸行动,并且坚持到底。
原文地址:https://www.cnblogs.com/wukc/p/13262947.html