Assume you created VM under libvirt and want to pass to this VM USB2Ethernet adapter inserted to your host. From your host you need these three files for insert and remove USB device and xml file with it’s definition:
When you inserted USB via ./insert_usb.sh you will see it in your VM via lsusb for example. Just a reminder of how to login to it:
sudo virsh console your_vm_name
But when you check it out via ifconfig, you may notice that it can’t get IP address or got the one that is not in your network. The most easiest way is to make IP static.
Create /etc/systemd/network/my_adapter.network file at your VM. Filename must end with .network. Possible content:
[Match]
Name=enp0s1*
Name=eth*[Network]
Address=192.168.1.242/24
Restart network service (wiki):
systemctl restart systemd-networkd
Got it. See you.