redhat7安装后修改网卡配置(nmcli)
【摘要】 1.查看网卡信息[root@localhost ~]# nmcli connection show NAME UUID TYPE DEVICE ens224 ed8c24af-32ce-41d4-9cb0-50457f650009 ethernet ens224 ens256 b060629f-f32...
1.查看网卡信息
[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens224 ed8c24af-32ce-41d4-9cb0-50457f650009 ethernet ens224
ens256 b060629f-f32e-4b8e-982e-529e97643d81 ethernet ens256
2.新增eth0和eth1网卡文件
[root@localhost ~]# nmcli connection add con-name eth0 ifname ens224 type ethernet
[root@localhost ~]# nmcli connection add con-name eth1 ifname ens256 type ethernet
3.删除ens224和ens256网卡文件
[root@localhost ~]# nmcli connection down ens224
[root@localhost ~]# nmcli connection down ens256
[root@localhost ~]# nmcli connection delete ens224
[root@localhost ~]# nmcli connection delete ens256
4.查看网卡的Mac地址
[root@localhost ~]# ip link show
eth0:00:0c:29:ee:90:77
eth1:00:0c:29:ee:90:81
5.修改网卡配置文件的device名称并新增mac地址参数HWADDR
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
HWADDR=00:0c:29:ee:90:7
DEVICE=eth0
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
HWADDR=00:0c:29:ee:90:81
DEVICE=eth1
6.ip link修改device名称
[root@localhost ~]# ip link set ens224 down
[root@localhost ~]# ip link set ens256 down
[root@localhost ~]# ip link set ens224 name eth0
[root@localhost ~]# ip link set ens256 name eth1
[root@localhost ~]# ip link set eth0 up
[root@localhost ~]# ip link set eth1 up
7.重新加载网卡文件
[root@localhost ~]# nmcli connection up eth0
[root@localhost ~]# nmcli connection up eth1
[root@localhost ~]# nmcli connection reload
8.重启网络服务
[root@localhost ~]# systemctl restart network.service
9.查看网卡信息
[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
eth0 e5966e4d-fa43-4e0c-8962-5403ca1c88eb ethernet eth0
eth1 0d1a07f5-a52f-4b38-b02f-405b0e3e32ac ethernet eth1
【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)