GreatSQL社区

搜索

vatebur

Esxi 网卡(Pcie)直通的坑

vatebur 已有 2537 次阅读2022-12-13 14:44 |个人分类:MySQL学习|系统分类:故障排错

Esxi 网卡直通的坑

省流请到文章末尾的总结。

前阵子买了个N5105 突发奇想打算给OpenWrt装一个Pci无线网卡。但装后发现Web管理界面上不去了,OpenWrt网络管理功能也全失效了。插显示器发现管理口从eth0 变成了etc3 口。拔掉Pci 网卡后又好了,管理口也变回了eth0口。

环境介绍

N5105 小主机,I225-V网卡,4网口,Esxi 8 系统。eth0 做管理口;eth1,eth2,eth3 直通给OpenWrt 。

其中 eth0 ,eth1,eth2 在OpenWrt中定义为Lan口,eth3 为Wan 口。

各网口Pci地址如下

0000:02:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V  #eth0
0000:03:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V    #eth1(直通
0000:04:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V    #eth2(直通
0000:05:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V    #eth3(直通

故障定位

连显示器进后台,

先用 lspci命令查看一下各网口的Mac地址和pci通道

插pci网卡之前

[root@localhost:~] lspci
0000:01:00.0 Non-Volatile memory controller: ****** Corporation NVMe SSD         #固态硬盘
0000:02:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V  #eth0
0000:03:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V    #eth1(直通
0000:04:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V    #eth2(直通
0000:05:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V    #eth3(直通

插pci网卡之后

[root@localhost:~] lspci
0000:01:00.0 Non-Volatile memory controller: ****** Corporation NVMe SSD        #固态硬盘
0000:02:00.0 Network controller: MEDIATEK Corp. MT7921 802.11ax PCI Express Wireless Network Adapter                                                                #Pci网卡
0000:03:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V  #eth0
0000:04:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V    #eth1
0000:05:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V    #eth2
0000:06:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V    #eth3

注意看前面的PCI地址0000:02:00.0 ,新加的Pci无线网卡 MT7921 ,把原本属于eth0的 0000:02:00.0 地址占用了,导致有线网卡的Pci地址全后移了一位。

故障分析

因为 Esxi 是根据Pci地址进行直通,再插入前 我直通了eth1,eth2,eth3 三个网口,直通pci地址为:0000:03:00.0、   0000:04:00.00000:05:00.0  

插入之后由于Pci 地址发生了变化,导致

0000:03:00.0 从eth1 变成了eth0,
0000:04:00.0 从eth2 变成了eth3,
0000:04:00.0 从eth3 变成了eth4。

所以直通的网口变成了:eth0,eth1,eth2。如下所示:

0000:02:00.0 Network controller: MEDIATEK Corp. MT7921 802.11ax PCI Express Wireless Network Adapter                                                                #Pci网卡
0000:03:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V  #eth0(直通
0000:04:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V    #eth1(直通
0000:05:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V    #eth2(直通
0000:06:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V    #eth3

eth0 变成了直通口,eth3变成了不直通的口,因为此时只有eth3没有直通,所以eth3变成了管理口。所以导致连不上管理界面。此时OpenWrt里的网口也乱了。然后就出现了后面的问题。至此问题以及分析完毕。

解决方案

方案一:通过命令改变直通的Pci 通道。

方案二:拔掉网卡,在Web后台更改直通设置后插入。

方案一具体实现步骤:

在Esxi 最开始界面按F1+alt就能进入控制台。通过以下命令控制直通Pci通道

esxcli hardware pci pcipassthru set -d <网卡的PCIE地址> -e TRUE      #直通改网口
esxcli hardware pci pcipassthru set -d <网卡的PCIE地址> -e FALSE        #不直通改网口

在我的案例里 我需要输入

esxcli hardware pci pcipassthru set -d 0000:02:00.0 -e TRUE     #直通无线网卡
esxcli hardware pci pcipassthru set -d 0000:03:00.0 -e FALSE    #不直通eth0口,作为esxi管理口
esxcli hardware pci pcipassthru set -d 0000:06:00.0 -e TRUE        #直通eth3口

然后再进入OpenWrt把网口该对就行了

补充

物理网口的mac地址是固定的,可以通过mac地址来判断 pci地址对应的是哪个物理网卡

使用命令,可以看到网口mac地址和pci地址。但是只能看到没直通的网口。

esxcli network nic list

esxi快捷键

ALT+F1 = 切换到控制台。
ALT+F2 = 切换到 DCUI。
ALT+F11 = 返回横幅屏幕。
ALT+F12 = 在控制台上显示 VMkernel 日志。

总结

因为 Esxi 是根据Pci地址进行直通,插入Pci无线网卡后,各设备的Pci地址发生了变动。导致直通的设备发生了改变,原先的管理口被直通了。根据新的Pci地址重新设直通的网口就行了。


评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

合作电话:010-64087828

社区邮箱:greatsql@greatdb.com

社区公众号
社区小助手
QQ群
GMT+8, 2024-4-25 21:48 , Processed in 0.013048 second(s), 8 queries , Redis On.
返回顶部