ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Centos8 配置网络 nmcli的使用

2022-02-15 16:02:24  阅读:223  来源: 互联网

标签:nmcli 网络 网卡 connection IP6 ipv4 Centos8 eth0


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'.

 

标签:nmcli,网络,网卡,connection,IP6,ipv4,Centos8,eth0
来源: https://www.cnblogs.com/feifa/p/15896879.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有