Configure QEMU Bridge Network in Ubuntu 14.04

This writing will provide an easy to follow, step by step guide to configure a QEMU  Bridge Network in Ubuntu 14.04 host machine. Though I’ve done it in Ubuntu 14.04 machine, I believe it’ll also work on Ubuntu 12.04.

By default, QEMU VM uses user networking which allows the VM to

  • acess resources from the host computer
  • access internet
  • access resources from local network

But the user networking doesn’t allow us to:

  • access the virtual machine from the host machine
  • access the virtual machine from local network

Hence comes the concept of QEMU bridge network which will allow us to assign an IP address to our QEMU VM and make it accessible from any computer connected to the local network. One possible use case might be to run a web server inside QEMU VM. So let’s follow the easy steps below to configure a QEMU bridge network.

 

Create A Bridge and name it br0:

$sudo brctl addbr br0 
$sudo brctl addif br0 eth0 
$sudo ip link set up dev br0 
$sudo ip addr add dev br0 192.168.66.66/24

Configure QEMU:

There should be a “qemu-bridge-helper” file in either “/usr/local/libexec/” directory or “/usr/lib” directory. Execute the following command on this file:

$sudo chmod u+s /usr/local/libexec/qemu-bridge-helper

or

$sudo chmod u+s /usr/lib/qemu-bridge-helper

If you don’t have a “bridge.conf” file in “/etc/qemu/” directory, create it. You’ll need root permission to do that. This file will be used for Access Control. We want to allow our created bridge “br0“. So add following line in “bridge.conf” file.

allow br0

Run QEMU:

You are all set with establishing a bridge. Now run QEMU with following command:

$ sudo qemu-system-x86_64 -enable-kvm -hda Ubuntu.img -monitor stdio -netdev bridge,id=hn0 -device virtio-net-pci,netdev=hn0,id=nic1

You can get more help here

In case it doesn’t work for any other Ubuntu version or some command fails, let me know so I can assist and update my post.