Setting up networking in Qemu for using OpenNSM

Geek00L has created a OpenBSD 4.0 based QEMU image called OpenNSM which I decided to give a try. Getting the networking part to work with my Linux host was a bit of a puzzle, so i’m writing it down here. Most of the steps were taken from the unofficial qemu wiki page here, but not all of them were necesarry.

First of all, I had to use the QEMU version 0.8.2 from the QEMU website, because the 0.8.0 version from my Ubuntu Dapper workstation didn’t work. With the latter version the OpenBSD bootup would just hang at the message ‘clock: Unknown CMOS layout’.

For the networking to work, I needed to setup a bridge between the actual NIC and the tap interface that QEMU was going to talk to. First the tap:

modprobe tun
chmod a+rwx /dev/net/tun

Next the bridge setup on eth1. The tap was added to it later.

brctl addbr br0
ifconfig eth1 0.0.0.0 up
brctl addif br0 eth1

Added an IP Address to the bridge in the subnet connected to the eth1 NIC.

ifconfig br0 192.168.2.12

After this I setup the file /etc/qemu-ifup. This file is called by QEMU on startup to setup the tap networking.

#!/bin/sh
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
sudo /usr/sbin/brctl addif br0 $1

Now I was ready to start the image:

qemu -hda OpenNSM.img -m 256 -net nic -net tap

Once the image was booted, I made the corrections described by Geek00L here. Finally, I ran /root/nsm-scripts/net-config.sh in the OpenBSD installation to setup the system with a unique IP Address. I chose 192.168.2.13. After this I could use networking from my OpenNSM installation šŸ™‚

3 thoughts on “Setting up networking in Qemu for using OpenNSM

  1. Thank you! you are a god! šŸ˜€

    I’ve reading 5,6 manuals about tap and tun and I had no luck…

    Your manual it’s the first sucessful networking on KVM/QEMU using new kernel virtualization, and i have Internet into my guest now…

    Thanks!

  2. To use brctl you will need to install bridge-utils šŸ™‚
    # apt-get install bridge-utils
    (I’m using Debian Stable 4.0 a.k.a. ETCH)

    I’ve tried to follow this post but I did not have the brctl util (DUH!)
    So.. Google said that bridge-utils is required!

    Thanks from Brazil for the post, dude. Helps a lot!
    Great job šŸ˜‰

  3. Pingback: Qemu Network on Linux « WebDrops

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s