Setting up USB Ethernet Passthrough in PVE 6.x

Publish: 2023-08-21 | Modify: 2023-08-21

Recently, I installed a mobile enterprise dedicated line and plan to deploy it using a software router. Currently, I only have one Tianbao Mini Host, but it only has one gigabit Ethernet port, which is not suitable for use as a software router. Therefore, I purchased a "USB to RJ45 adapter" to add an Ethernet port to solve this problem.

Choosing a USB to RJ45 Adapter

When choosing a USB Ethernet adapter, the following requirements must be met:

  • Support gigabit Ethernet or higher
  • Support Linux (preferably plug and play)

I have found two USB Ethernet adapters that meet the requirements:

I have used the Green Alliance adapter before, and it can be recognized and used normally by iKuai software router. This time, I plan to try the TP-LINK adapter, which costs 79 yuan, slightly more expensive than the Green Alliance one.

Hardware & Software Setup

  • Hardware: Tianbao Mini Host * 1
  • Hardware: TP-LINK USB to RJ45 Ethernet Adapter * 1
  • Hardware: 8-port gigabit switch * 1
  • Software: Mini Host already installed with PVE 6 and running services
  • Software: Planning to install iKuai software router system in PVE 6 using virtual machine

Installing iKuai Software Router System in PVE 6

In "PVE Backend - Data Center - PVE - local", upload the downloaded ISO image.

49735874ba07d436.png

Create a virtual machine without any special settings. Note that the CPU priority should be set higher, and the 64-bit iKuai system requires at least 4GB of memory. I only allocated 15GB of disk space.

Setting Up USB Ethernet Passthrough in PVE 6.x

First, insert the purchased USB Ethernet adapter into a USB 3.0 port, and then enable hardware passthrough in PVE. The methods for Intel and AMD are different, as follows:

  1. Check if the system supports IOMMU

    First, you need to make sure that your CPU and motherboard support IOMMU technology (e.g., Intel VT-d or AMD-Vi).

    Execute the following command to check if IOMMU is enabled:

    dmesg | grep -E "DMAR|IOMMU"

    If you see output related to IOMMU or DMAR, then your system supports it.

  2. Enable IOMMU

    If IOMMU is not already enabled, you need to enter the BIOS/UEFI settings and enable Intel VT-d (for Intel platforms) or AMD IOMMU (for AMD platforms).

    At the same time, you need to enable IOMMU in Proxmox's GRUB configuration. For most systems, edit the /etc/default/grub file and add the relevant IOMMU options:

    • For Intel:
      GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"
    • For AMD:
      GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on"

    Update GRUB and reboot the machine:

    update-grub
    reboot
  3. Find the PCI ID of the device to passthrough

    Use the following command to list all PCI devices:

    lspci -nn

    Find the network card you want to passthrough and take note of its PCI ID (e.g., 02:00.0).

  4. Add device passthrough to Proxmox

    In /etc/pve/nodes/YOUR-NODE-NAME/qemu-server/YOUR-VM-ID.conf (where YOUR-NODE-NAME is your Proxmox node name and YOUR-VM-ID is the ID of the virtual machine), add the following line:

    hostpci0: 02:00.0

    Note: The PCI ID 02:00.0 above is an example, you should use the actual ID you found in step 3.

  5. Start the virtual machine

    Now, when you start the virtual machine, the network card should be passed through to it, and you should be able to see the device in the operating system of the virtual machine.

Please note that passing through hardware to a virtual machine may cause stability and security issues, so be sure to perform sufficient testing before using it in a production environment.

The above method was provided by ChatGPT and has been tested by me. However, in steps 3 and 4, since the USB Ethernet adapter is not a PCI device, you should choose USB instead of PCI when adding the hardware. I performed the operation through the PVE web interface, as follows.

"Select your virtual machine - Hardware - Add - USB Device"

06a6b81b506632d8.png

Find the USB Ethernet adapter that was just inserted and add it.

3c42988620cf9ebf.png

Restart the iKuai virtual machine, and then the Ethernet port should be recognized normally.

Other Notes

During the whole process, I did not install any additional network card drivers. If you, like Xiaoz, need to install a software router on a mini host with only one Ethernet port, you can try using a "USB to RJ45 Ethernet adapter" to achieve it.


Comments