KVM - The Linux Kernel-Based Virtual Machine
News, Blogs and Resources on the Linux (KVM) Kernel-Based Virtual Machine

QEMU and KVM virtual network [bridge vlan tap] ?

1 reply [Last post]
netgate
Offline
Joined: Oct 24 2011
Points: 5

Hello everyone,

I've been looking around on the forum for a solution to my problem but I didn't found it...

1st part of my problem:
I have 3 VMs working with QEMU KVM on a same host, I would like those VM to be able to comunicate together on private IP addresses (I do not want them to be reacheable from outside), I tought about making a bridge on the host and just giving the addresses to the VM using tap...
To do that I have setup this into my host /etc/network/interfaces:

Code:
# The loopback network interface
auto lo eth1 tap01 tap02 br0
iface lo inet loopback

iface eth1 inet dhcp

iface tap03 inet manual
pre-up tunctl -u g -t tap03

iface tap02 inet manual
pre-up tunctl -u g -t tap02

iface tap01 inet manual
pre-up tunctl -u g -t tap01

iface br0 inet static
bridge_ports tap01 tap02 tap03
bridge_maxwait 0
address 172.168.1.10
netmask 255.255.255.0

And on each VM I just declare a static network address this way:

Code:
iface eth0 inet static
address 172.168.1.x
netmask 255.255.255.0

And I launch the VMs this way:

Code:
kvm -m 512 vm1.img -net nic -net tap,ifname=tap01 &
kvm -m 512 vm2.img -net nic -net tap,ifname=tap02 &
kvm -m 512 vm3.img -net nic -net tap,ifname=tap03 &

I use tap because otherwise the host system does not see the VMs ethernet interfaces.

Well this does not work, each VM can ping the bridge but they can not reach each other.
I must be doing something wrong, does the bridge need an IP address ? should I declare the VM's IP in the host machine or just like I do, in the VM machines themselves ?

Because I've been reading a lot of topics I'm not sure about how to do, i tried to use a vlan by starting the VMs like this:

Code:
qemu VM.img -net nic,model=rtl8139,vlan=1 &

This does not work anymore :(

Thanks for your help, any sugestions are welcome ;)

netgate
Offline
Joined: Oct 24 2011
Points: 5
This is a very good

This is a very good solution:

In the host machine this is the network you should use:

[code]
# The loopback network interface
auto lo eth1 br0 br1 br2 br3

iface lo inet loopback

iface eth1 inet dhcp

iface br0 inet manual
bridge_ports none
address 0.0.0.0
netmask 0.0.0.0
bridge_stp off
bridge_fd 5

iface br1 inet manual
bridge_ports none
address 0.0.0.0
netmask 0.0.0.0
bridge_stp off
bridge_fd 5

iface br2 inet manual
bridge_ports none
address 0.0.0.0
netmask 0.0.0.0
bridge_stp off
bridge_fd 5

iface br3 inet manual
bridge_ports none
address 0.0.0.0
netmask 0.0.0.0
bridge_stp off
bridge_fd 5
[/code]

And then install libvirt:

[code]
apt-get install virt-manager libvirt-bin virtinst
[/code]

This should help you getting the rights:

[code]sudo adduser $USERNAME libvirtd[/code]

Close and re-open your session.

And now lauch the manager, the rest is friendly user enought to find it by yourself...

[code]virt-manager -c qemu:///system[/code]

Post new comment

The content of this field is kept private and will not be shown publicly.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.