Home Posts


QEMU and the network bridge

QEMU’s user networking won’t do UDP out of the box, so I poked around online for a solution. What’s out on the web is a hodge-podge of tutorials, all of them different, and most of them for a non-current (read: not QEMU 0.8.0) release. This is a (equally poor) guide to get bridged networking working. FYI, my distro du jour is Ubuntu 5.10, and I hope to revise these instructions should the need arise to re-configure my setup.

First, check out How to install QEmu on Ubuntu Linux (Breezy) for some aptly named instructions.

From the tun/tap on ubuntu thread on Ubuntu Forums (probably not necessary?):

# apt-get install uml-utilities # tunctl

From qemu 'networking howto':

# ifconfig eth0 down # brctl addbr br0 # ifconfig eth0 0.0.0.0 promisc up # ifconfig tun0 0.0.0.0 promisc up # ifconfig br0 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255 up # brctl stp br0 off # brctl setfd br0 1 # brctl sethello br0 1 # brctl addif br0 eth0 # brctl addif br0 tun0 # route add default gw 192.168.1.1

From djw's qemu network bridge page, modify your /etc/qemu-ifup to something like:

#!/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

Finally, what they never tell you is how to start up QEMU. Little did I know that when you connect TAP to a VLAN, it doesn’t create the NIC for you. I wasted about a hour until I realized you need to append another -net nic. Here’s how I start QEMU:

qemu debian.img -kernel bzImage-2.6.14 -append "root=/dev/hda1" -net tap -net nic

Voila, mon ami. C’est tout!

Update: You’ll want to chmod 666 /dev/net/tun, and make sure you have the bridge-utils package.

Update 2: I have kernel config files for Linux 2.4.20, 2.6.11 (found these first two online), and 2.6.14. These build decently small kernels without modules that boot up in QEMU.

Thomas Kho - 18 Feb 2006



The opinions expressed on this site are mine and do not necessarily represent those of my employer.