qemu/kvm tap networking

Date January 6, 2010

The following is the commands to create a virtual bridge and virtual interfaces so you can use it with kvm/qemu tap networking, Actually i think you can do all of this using a GUI interface via Virtual Machine Manager (virt-manager), but i don't know why i feel its difficult to use it, anyway. You will need a tun enabled kernel, also tunctl and bridge-utils packages are installed in your system, in Fedora 12 i used yum to install them:
yum install bridge-utils.`uname -m` tunctl.`uname -m` -y
For tun support in your kernel, you can modprobe tun and see the result, or checking the config file under /boot/ for CONFIG_TUN, for example in fedora:
[root@shaker-testing ~]# egrep '^CONFIG_TUN' /boot/config-2.6.31.9-174.fc12.x86_64 CONFIG_TUN=m
anyway you do it, just make sure exist and probed (lsmod | grep tun) Finally here is the commands to create the virtual interface and virtual switch:
[root@shaker-testing ~]# tunctl -b -u root -t tap0 tap0 [root@shaker-testing ~]# brctl addbr testing-br [root@shaker-testing ~]# brctl addif testing-br tap0 [root@shaker-testing ~]# brctl addif testing-br eth0 [root@shaker-testing ~]# ifconfig tap0 0.0.0.0 promisc up [root@shaker-testing ~]# ifconfig eth0 0.0.0.0 promisc up [root@shaker-testing ~]# ifconfig testing-br 192.168.0.1 netmask 255.255.255.0 [root@shaker-testing ~]# brctl show bridge name    bridge id        STP enabled    interfaces testing-br        8000.0019d13401c0    no        eth0 tap0
thats all, btw, 192.168.0.1 was my eth0  IP Address, you have to give it to your virtual bridge. now run your machine, i usually run it as followes:
qemu -hda /storage/testing1.img -m 256 -net nic,macaddr=00:1d:92:ab:3f:80 -net tap,ifname=tap0,script=no -alt-grab -vga std -name Testing1 -boot c -vnc :0
and then i login to it using vncviewer (i used -vnc :0 in the options) to configure its IP Address.. for example, if you are connecting/using it in localhost then i use:
vncviewer localhost:5900
or you can delete '-vnc:0' so you don't use vnc at all..
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Reddit
  • Webnews
  • MisterWong
  • Y!GG

One Response to “qemu/kvm tap networking”

  1. qemu/kvm tap networking | TuxWire : The Linux Blog said:

    […] more from the original source:  qemu/kvm tap networking Share and […]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>