从Centos7升级到Rocky linux 9后,网卡连接显示‘Wired connection 1‘问题解决方法

问题描述

从Centos7升级到Rocky9后, 发现网卡eth0的IP不正确。通过nmcli查看网卡连接,找不到name为eth0的连接,只显示’Wired connection 1’
在这里插入图片描述
查看/etc/NetworkManager/system-connections/,发现找不到网卡配置文件。

原因分析

centos7使用的网卡配置文件是ifcfg-files(/etc/sysconfig/network-scripts/ifcfg-XXX),而RHEL9使用的是keyfiles(/etc/NetworkManager/system-connections/XXX.nmconnection)。
升级到Rocky 9后,需要把eth0网卡重新配置一下。

解决方法

使用nmcli,先删除’Wired connection 1’这个连接,再为eth0网卡生成新的连接,方法如下:

# 删除 Wired connection 1 连接
nmcli dev disconnect eth0
nmcli con del c04f10b8-8831-3d68-9b79-2ac22907357c # nmcli con show 查找`Wired connection 1`连接的uuid,根据uuid删除连接
ip -4 route flush dev eth0

# 重新生成eth0连接 (这里设置static IP 10.206.216.91,网关10.206.216.254, dns 8.8.8.8)
nmcli con add con-name eth0 autoconnect yes  type ethernet ifname eth0 ipv4.method manual ip4 "10.206.216.91/24" gw4 "10.206.216.254"  ipv4.dns "8.8.8.8"
nmcli c up eth0

参考

https://www.redhat.com/en/blog/rhel-9-networking-say-goodbye-ifcfg-files-and-hello-keyfiles

  • 5
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

pcj_888

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值