Qemu

Bridged networking

Setup

Many thanks to (the extremely helpful) WaxDragon in irc.freenode.net/#qemu, who managed to crunch the bugs out of this setup (twice).

# /etc/network/interfaces
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet manual
#       address 192.168.2.108
#       netmask 255.255.255.0
#       gateway 192.168.2.1

auto br0
iface br0 inet static
        address 192.168.2.108
        network 192.168.2.0
        netmask 255.255.255.0
        broadcast 192.168.2.255
        gateway 192.168.2.1
        bridge_ports eth0
        bridge_fd 9
        bridge_hello 2
        bridge_maxage 12
        bridge_stp off

Start qemu with:

-net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=/etc/qemu-ifup

qemu-ifup should contain:

#!/bin/sh

echo "Executing /etc/qemu-ifup"
echo "Bringing up $1 for bridged mode..."
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
echo "Adding $1 to br0..."
sudo /usr/sbin/brctl addif br0 $1
sleep 2

Troubleshooting