ipvtap is similar to macvtap, but works over wifi too, since it uses the same mac address as the wifi interface.
libvirt doesn't support ipvtap, so we have to configure everything manually. Important data we need before we start:
- the name of the wifi interface,
wlan0
in my case (it's already connected - use NM or networkd+iwd). - the mac address of the wifi interface (it must be the same in the guest too)
On the host:
sudo ip link add name ipvtap0 link wlan0 type ipvtap mode l2 bridge
sudo ip link set up ipvtap0
The network interface for the guest is configured via the following xml
using the mac address from wlan0/ipvtap0:
<interface type="ethernet">
<mac address="f8:d1:11:18:81:c3"/>
<target dev="ipvtap0" managed="no"/>
<model type="virtio"/>
<alias name="net0"/>
<address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
</interface>
⚠️ DHCP is a … bit complicated
Now, I can start the VM, but I can't ping from/to router to/from the VM, until I configure the guest address on the host ipvtap0 too:
sudo ip addr add dev ipvtap0 192.168.17.111/32
this might be fixable with some proxy-arp?
Host:
- Archlinux, 5.6.15-arch1-1
- libvirt 6.4.0-1
- qemu-headless 5.0.0-6
Guest:
- Archlinux testing, 5.7.0-zen1-1-zen
For DHCP you still need to configure the ipvtap0 ip, host side, manually.
That being said, you can use:
dhcrelay -d -4 -id ipvtap0 -iu wlp0s20f3 192.168.1.1
to get a DHCP reply inside the guest and get the interface (guest-side) configured.
You'll still need to discover which IP is that (that the guest received) to configure ipvtap0. If guest-side IP was 192.168.1.123, then you'd still need to do
sudo ip addr add dev ipvtap0 192.168.1.123/32
on the host