C/C++教程

Centos8 配置网络 nmcli的使用

本文主要是介绍Centos8 配置网络 nmcli的使用,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1.网卡查看

nmcli c = nmcli connection show

[root@centos8 ~]# nmcli c
NAME  UUID                                  TYPE      DEVICE 
eth0  6ace3223-0c8c-4e95-a41f-7520a377b492  ethernet  eth0   

nmcli c s = nmcli connection show eth0 #查看网卡信息

[root@centos8 ~]# nmcli c s eth0
connection.id:                          eth0
connection.uuid:                        6ace3223-0c8c-4e95-a41f-7520a377b492
connection.stable-id:                   --
connection.type:                        802-3-ethernet
connection.interface-name:              eth0
……
IP6.GATEWAY:                            fe80::fa98:efff:fef1:e812
IP6.ROUTE[1]:                           dst = 2001:da8:21d:3::/64, nh = ::, mt = 100
IP6.ROUTE[2]:                           dst = ::/0, nh = fe80::fa98:efff:fef1:e812, mt = 100
IP6.ROUTE[3]:                           dst = ff00::/8, nh = ::, mt = 256, table=255
IP6.ROUTE[4]:                           dst = fe80::/64, nh = ::, mt = 100
IP6.ROUTE[5]:                           dst = 2001:da8:21d:3::54/128, nh = ::, mt = 100
IP6.DNS[1]:                             2001:da8:21d:1::6
DHCP6.OPTION[1]:                        dhcp6_name_servers = 2001:da8:21d:1::6
DHCP6.OPTION[2]:                        ip6_address = 2001:da8:21d:3::54

显示所有设备配置状态

[root@centos8 ~]# nmcli device status 
DEVICE  TYPE      STATE   CONNECTION 
eth0    ethernet  已连接  eth0       
lo      loopback  未托管  --  

 

2.网卡配置

nmcli掩码和IP写到一起了 

  • 255.0.0.0/8
  • 255.255.0.0/16
  • 255.255.255.0/24

nmcli connection modify eth0 ipv4.method manual

nmcli connection modify eth0 ipv4.addresses 192.168.0.58/24 ipv4.gateway 192.168.0.2 ipv4.dns 114.114.114.114

删除DNS

# nmcli connection modify eth0 -ipv4.dns 114.114.114.114

添加一个网卡

nmcli connection add type ethernet con-name eth0 ifname eno123

添加一个ipv4

# nmcli connection modify eth0 +ipv4.addresses 192.168.10.159/24

 

3.网卡重启

nmcli connection up eth0  打开网卡

nmcli connection down eth0  关闭网卡

# 配置完后使用如下任意两条命令执行加载配置 更新网卡的操作

[root@rhel8 ~]# nmcli device connect eth0
Device 'eth0' successfully activated with '6ee6c69c-7753-4ef0-8f95-5be18adc75db'.

[root@rhel8 ~]# nmcli device reapply eth0
Connection successfully reapplied to device 'eth0'.

 

这篇关于Centos8 配置网络 nmcli的使用的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!