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.
When choosing a USB Ethernet adapter, the following requirements must be met:
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.
In "PVE Backend - Data Center - PVE - local", upload the downloaded ISO image.
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.
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:
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.
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:
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on"
GRUB_CMDLINE_LINUX_DEFAULT="quiet amd_iommu=on"
Update GRUB and reboot the machine:
update-grub
reboot
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
).
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.
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"
Find the USB Ethernet adapter that was just inserted and add it.
Restart the iKuai virtual machine, and then the Ethernet port should be recognized normally.
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.
I come from China and I am a freelancer. I specialize in Linux operations, PHP, Golang, and front-end development. I have developed open-source projects such as Zdir, ImgURL, CCAA, and OneNav.