前言
在虚拟机重新配置网卡后 网卡名称从ens33变为ens34
但是在/etc/sysconfig/network-scripts/下无ifcfg-ens34配置
操作
# 查看所有网络连接
$ nmcli conn
NAME UUID TYPE DEVICE
ens33 uuid ethernet ens33
ens37 uuid ethernet ens37
Wired connection 1 uuid ethernet ens34
# 删除网络连接的配置文件
$ nmcli conn delete 'Wired connection 1'
Connection 'Wired connection 1' (uuid) successfully deleted.
# 添加网络连接的配置文件
$ nmcli conn add con-name ens38 ifname ens38 type ethernet
Connection 'ens38' (uuid) successfully added.
# 修改网络连接的配置文件
$ nmcli conn modify ens38 ipv4.method manual ipv4.address 192.168.10.2/24 autoconnect yes
$ systemctl restart network
$ ip addr
# 发现网卡配置文件已经出现了
$ vim /etc/sysconfig/network-scripts/ifcfg-ens38
同时删除老的ifcfg-ens33
systemctl restart network
参考文章
https://blog.csdn.net/weixin_44654329/article/details/106575526