在CentOS7.9中,系统默认采用3.10内核,由于centos7系列发布不于2014年,对后来的I225/I226(125)网卡等新网卡缺乏相应驱动,导致无法识别。
具体表现为,执行 lspci | grep -i ethernet 能查看到设备,
01:00.0 Ethernet controller: Intel Corporation Device 125c (rev 04)
02:00.0 Ethernet controller: Intel Corporation Device 125c (rev 04)
03:00.0 Ethernet controller: Intel Corporation Device 125c (rev 04)
04:00.0 Ethernet controller: Intel Corporation Device 125c (rev 04) 但是,使用 ifconfig 或者 ip add 无法看到相应网卡设备。
解决思路
这时候有两种办法可以解决:
1.自行编译安装网卡驱动
2.升级系统内核
方案分析
两个方案都有优缺点,自行编译网卡驱动:相关资源需要自行查找,由于centos7的相关资源多被下线,查找资料有难度。升级系统内核:经过资料查找并尝试发现,5.10以上内核完美支持I225/I226(125c),但是升级内核会面临环境兼容问题,容易导致整个系统奔溃。
我先尝试了自行编译网卡驱动,多次尝试以后,发现相关驱动下载链接均已经403(可能豆包太辣鸡了)。由于我是新环境,上面并没有数据,故我采用升级内核这一简单办法处理。
资源下载及安装
由于机器无法识别网卡,所以需要从其他电脑上下载内核或者使用手机USB共享网络下载,然后上传到识别有问题的服务器上。
目前找到的可用rpm源:
[root@test ~]# wget https://dl.lamp.sh/kernel/el7/kernel-ml-devel-5.10.222-1.el7.x86_64.rpm
[root@test ~]# wget https://dl.lamp.sh/kernel/el7/kernel-ml-5.10.222-1.el7.x86_64.rpm
#安装内核
[root@test ~]# rmp -vih kernel-ml*.rpm
#检查是否已安装
[root@test ~]# ls /boot/vmlinuz-* | grep 5.10
#生成grub文件
[root@test ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
#设置默认内核并重启验证
[root@test ~]# grub2-set-default 0
[root@test ~]# reboot 重启后我们执行 uname -a 检查下当前内后是否是我们需要的内核。
[root@test ~]# uname -a
Linux test 5.10.222-1.el7.x86_64 #1 SMP Thu Jul 18 13:09:27 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux 如果内核升级成功,基本上使用 ifconfig 或者 ip add 就可以看到相应网卡设备了。
[root@test ~]# ifconfig
eno1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 60:be:b4:08:e2:f6 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xa1300000-a13fffff
enp1s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 60:be:b4:08:e2:f4 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xa1700000-a17fffff
enp2s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 60:be:b4:08:e2:f5 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xa1500000-a15fffff
enp4s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 60:be:b4:08:e2:f7 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0xa1100000-a11fffff
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 32 bytes 2592 (2.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 32 bytes 2592 (2.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
记录个小命令
查看网卡UUID:
nmcli con show 或 nmcli con list
查看网卡mac地址:
nmcli dev show 或 nmcli dev list
注:show用于7版本;list用于6版本;