After two years of using VMWare Server under Linux to load up virtual machines to do development, I started to become frustrated with its poor disk IO performance. I have been growing impatient for a while, but last week finally decided to give KVM a try. I read some very good things about KVM's performance, especially on Intel or AMD chips that support virtualization. Setup was painless, I just apt-get'd the kvm package and everything was ready to go. The default network settings under KVM is to NAT a connection through the host's outgoing interface, giving the guest OS has access to the outside world. Unfortunately, if any machine needs to connect to the guest, under the default setup, there is no way to do this. I often start up a web server on my development guest and use other guest VMs to test how different browsers under different operating systems view what I am developing. This means I need to be able to access port 80 on the development virtual machine.

There are plenty of articles showing how to bridge an interface in KVM to give the functionality that I want, with a caveat that most wireless cards cannot do this. A huge problem on my laptop where I connect the LAN cable once per year. I found a post by bodhi.zazen that shows how to bridge a wireless card in KVM using a TUN/TAP device, just what I need.

The solution worked without flaw, but the approach meant that I needed to reserve an IP address on a network that is otherwise completely served by DHCP. Linux NAT to the rescue. My revised approach is to set up a TUN/TAP device, give the device an IP address, which under linux creates a route to that network, and we can easily access services on the virtual machine without polluting the external networks IP address space.

Follow the approach in bodhi.zazen's post until step 5.

Modified step 5:

Configuration. This step is a bit complex.

A : Network. Assume a network of with a router (used for DNS) at
B : Ignore this, our step changes this in step C.
C : Tap. We assign a ip address to the tap, it will become the default gateway for the guest.  By setting up this IP address, linux will create a route to the guest's network.
tap's IP address =
D: Guest. DHCP does not work so you will need to manually configure a static IP address of the guest.
IP address = route we assign to the tap, in this example
Netmask =
Default gateway =
DNS (nameserver) =
With that background …
ip link set tap0 up
ifconfig tap0

Start step 6 until:

Address = <- From the route command.
Change this next section to:
Address = <- From the route command.
Netmask =
Gateway = <- IP address of the host.
In the DNS Servers box use
Click the "Apply" box.
Finally, follow his "extra credit" portion. That's it , it should be working.