Linux – Wireless bridge on KVM virtual machine

linux-kvmnetworkingvirtual machinewireless-bridge

I have a VM host (KVM) that's connected to a wireless router. I'd like the virtual guests to be in the same broadcast domain as the host; i.e, receive their IP from the router's DHCP. (=Layer 2 bridging)

According to KVM documentation it's impossible: Important Note: Unfortunately, wireless interfaces cannot be attached to a Linux host bridge, so if your connection to the external network is via a wireless interface ("wlanX"), you will not be able to use this mode of networking for your guests. (I tried it anyway, and indeed, it doesn't work 🙂 )

There are some resources in the Internet that suggest how to make a routed interface, and it works for me. But it's Layer 3, and the guests reside in a different IP subnet.

However, I used VirtualBox in the past – and wireless bridging works there.

I've found superuser question regarding VirtualBox, that explains: Many virtual machine programs come with a special "bridge" or "filter" driver which attaches to existing network interfaces and allows the program to send and receive packets (Ethernet frames) directly.

That's exactly the outcome I want – KVM virtualization with Ethernet bridging (Layer 2).
Sadly, it appears that libvirt/KVM don't include such as a driver. But I assume that it can be achieved with some other Unix tool.

Best Answer

I had exactly the same requirement as Zvika. By the way, his post on the subject is excellent. The alternative I found is this: configure a routed network in KVM in the range 192.168.1.160/28 (so, dedoimedo third solution, the "dirty hack") and then, instead of creating an ARP proxy the Zvika's way, I used parprouted, which is available in Ubuntu/Mint as a package with the same name. With parprouted, you can just type:

sudo parprouted virbr1 wlan0

et voilà, traffic works in both ways to/from the guest VM and the other devices in 192.168.1.0/24 network, as well as to/from external systems (e.g. Internet sites) if that network is behind a NAT.

This was hard, anyway, I spent days searching on this subject and no source was as clear as Zvika's blog entry!!

Related Question