I am trying to setup KVM in ubuntu 14.04 host machine.

  1. I use a wireless interface to access the internet in my machine. I have setup the wireless interface in my /etc/networks/interfaces as below.

    auto wlan0
    iface wlan0 inet static
    wpa-ssid My_SSID
    wpa-psk SSID_Password
    dns-search lan
    dns-domain lan
  2. I checked if my machine is available for virtualization and this command confirms that my hardware supports virtualization.

    egrep '(vmx|svm)' /proc/cpuinfo
  3. I installed the necessary packages for kvm virtualization as below.

    apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder
  4. I also installed the bridge utils package to configure bridge network for my kvm.

    apt-get install bridge-utils
  5. I modified my /etc/network/interfaces to allow the bridged network as below.

    auto br0
    iface br0 inet static
    dns-search lan
    dns-domain lan
    bridge_ports wlan0
    bridge_stp 0ff
    bridge_fd 0
    bridge_maxwait 0
    wpa-ssid my_ssid
    wpa-psk ssid_password
  6. After the above step, I am able to ping and also I could see there is br0 and virbr0 listed in the output of ifconfig -a command. I am also able to access the internet without any problem with my wireless interface.

  7. However, after the above step if I try to add another OS using ubuntu-vm-builder command, I am not able to add a new OS. This is the command I use to add a new OS.

    sudo ubuntu-vm-builder kvm trusty \
    --domain rameshpc \
    --dest demo1 \
    --hostname demo1 \
    --arch amd64 \
    --mem 1024 \
    --cpus 4 \
    --user ladmin \
    --pass password \
    --bridge br0 \
    --ip \
    --mask \
    --net \
    --bcast \
    --gw \
    --dns \
    --components main,universe \
    --addpkg acpid \
    --addpkg openssh-server \
    --addpkg linux-image-generic \
    --libvirt qemu;///system;  

I have seen that setting a bridged network using a wireless interface is quiet complicated as discussed in this question. However, as the answer describes it is possible using a tunneling device. I have tried the option as suggested in this link. But I couldn't get it to work.


As someone rightly said once, Nothing is impossible in LinuxTM, I could achieve the kvm in my host with a bridged network over a wireless interface.

These are the steps I followed to accomplish the same.

  1. I installed the virt-manager package to manage the installation more efficiently. I installed it as below.

    sudo apt-get install virt-manager
  2. Now, create a new sub-network using Virt Manager’s GUI as highlighted below. This is basically a sub network of our existing host network.

    enter image description here

  3. After setting this new sub-network, check if the network is available and ping some sites to check the network connectivity.

  4. Also, check the routing information using route command and make sure wlan0 and virbr2 doesn't have the same destination.

  5. Now, the final step to make it work is to issue the below command. Here is the host machine address.

    arp -i wlan0 -Ds wlan0 pub
  6. After the above step, I was able to successfully install a Fedora guest OS using the virt-manager.


http://specman1.wordpress.com/2014/01/02/wireless-bridging-virtual-machines-kvm/ https://superuser.com/questions/694929/wireless-bridge-on-kvm-virtual-machine

|improve this answer|||||
  • 2
    I had to enable ARP proxying on the interface: sudo sysctl net.ipv4.conf.wlan0.proxy_arp=1 – Leon Van Zyl Jun 28 '16 at 20:03
  • 2
    Instead of the Step 5 arp command instructions here, I used the instructions under "The future is here…" at specman1.wordpress.com/2014/01/02/… with success. echo 1 > /proc/sys/net/ipv4/conf/wlan0/proxy_arp and echo 1 > /proc/sys/net/ipv4/conf/virbr1/proxy_arp (I'm not necessarily saying the Step 5 arp command instructions here won't work; I'm just saying I didn't use them.) – dbank Mar 19 '18 at 2:29
  • 1
    I couldn't get it to work... every article says something different, none are clear enough to follow. Linux host windows guest. – TetraDev Apr 10 '19 at 21:27
  • @TetraDev: I were able to finally get this working, after about everything else failed. For some reason, this first was dying to some firewalld related error, but after I restarted libvirtd and/or shut “default” network down, I was able to add the “sub”-net, and with proxy_arp == 1, the connection really works. – Smar 2 days ago

According to KVM's docs, it is not possible to use a bridge with a wireless NIC. I do not know the reason why even though I used to bridge the guest on VirtualBox.

I have spent some few hours to figure out how to connect the guest to the host's wireless network and I found out the easiest way to do it is using a TAP device. The only disadvantage of this method is that you can't use DHCP on the guest and you have to manually give it an IP address from the wireless network subnet (Which may cause IP conflicts or inconvenience in case of deploying lots of VMs).

Here are the steps to connect the guest on the host's wireless network using a TAP device:

0/ Enable IPv4 routing for the Linux kernel

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

1/ Create a tap device named tap0 accessible from user guest (Replace with your username) without sudo:

sudo ip tuntap add mode tap tap0 user guest

2/ Assign an IP address to the tap0 device (It doesn't have to be from the wireless network subnet):

sudo ip addr add dev tap0
sudo ip link set tap0 up

3/ Use parprouted (You might have to install it) to implement proxy arp bridging which allows bridging the guest Ethernet behind the host's wireless NIC.

sudo parprouted wlan0 tap0

(Replace wlan0 with your host's wireless interface)

4/ Adding some routing tables entries to allows packets to travel through the ends of the tap device:

sudo iptables -A INPUT -i tap0 -j ACCEPT
sudo iptables -A FORWARD -i tap0 -j ACCEPT
sudo iptables -A FORWARD -o tap0 -j ACCEPT

On the guest assign a static IP address from the host's wireless network subnet. For example if your wlan0 is on then the guest can be configured with

sudo ip addr add dev eth0

(eth0 is your guest's NIC)

or permanently in /etc/network/interfaces with:

auto eth0
iface eth0 inet static

Launch your guest with:

kvm -hda guest.img -m 512 -net nic -net tap,ifname=tap0,script=no

Now pinging works between all machines connected on your wireless network and the guests.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.