【WMware】EXSi - 网卡直通

Posted by 西维蜀黍 on 2022-03-20, Last Modified on 2023-05-02

网卡直通(Passthrough)

如果以这样的顺序添加网卡,进入openwrt后

  • 0000:03:00:0 则为 openwrt中的eth0
  • 0000:02:00:0 为 openwrt中的eth1

直通后的网络设置

进入虚拟机后,检查所有直通的网络都被正确识别了

$ ip link

我计划这样,设置OpenWrt中各个逻辑网络接口

  • 将eth0 (对应物理接口ETH2)设置为 OpenWrt 的 WAN口
  • eth1 (对应物理接口ETH1)设置为OpenWrt的LAN口

启动虚拟机,进入OpenWrt后,

vi /etc/config/network
config interface 'loopback'
    option device 'lo'
    option proto 'static'
    option ipaddr '127.0.0.1'
    option network '255.0.0.0'
    
config globals 'globals'    
    option ula_prefix 'fd39:8bc0:f102::/48'

config interface 'lan'
    option device 'eth1'
    option proto 'static'
    option ipaddr '192.168.2.1'
    option netmask '255.255.255.0'
    option ip6assign '60'

在一台PC上,将该PC与软路由的唯一LAN口连接,OpenWrt会直接为其分配一个192.168.2.X的IP,ping一下192.168.2.1,表明链路正常。

因而,直接该PC上访问 192.168.2.1 即可访问到OpenWrt:

配置LAN网络

点击Network->Interfaces->选中LAN中的Edit,进入编辑LAN网络,确认 LAN下的网段已经设置为192.168.2.1,且只绑定到 eth1:

配置WAN网络

点击Network->Interfaces->选中WAN

让设置生效后,进入/etc/config/network 看一眼配置没有问题(如下则表示没有问题)

$ vim /etc/config/network
config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd09:f379:c0e1::/48'

config interface 'lan'
        option device 'eth1'
        option proto 'static'
        option ipaddr '192.168.2.1'
        option netmask '255.255.255.0'

config interface 'WAN'
        option proto 'dhcp'
        option device 'eth0'

Troubleshoot

网卡Intel I225 2.5G 直通后虚拟机中无法监测到网卡

root@OpenWrt:~# opkg update | grep pciutils
root@OpenWrt:~# opkg install pciutils

# 查看 I225是否已经正确被系统识别
root@OpenWrt:~# lspci 
...
03:00.0 Ethernet controller: Intel Corporation Ethernet Controller I225-V (rev 03)

# 确认 driver是否可以被安装
root@OpenWrt:~# opkg list | grep kmod-igc
kmod-igc - 5.4.179-1 - Kernel modules for Intel(R) Ethernet Controller I225 Series
# install
root@OpenWrt:~# opkg install kmod-igc
Installing kmod-igc (5.4.179-1) to root...
Downloading https://downloads.openwrt.org/releases/21.02.2/targets/x86/generic/packages/kmod-igc_5.4.179-1_i386_pentium4.ipk
Configuring kmod-igc.

Ref

Memory Reservation should be equal to memsize

To resolve this issue:

  1. Right-click the virtual machine and click Edit settings.
  2. Click the Resources tab.
  3. Select Memory and increase the reservation amount to its configured memory size.
  4. Click OK.
  5. Power on the virtual machine.

Ref

Reference