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

kvm troubles with vlan switch

4 replies [Last post]
dcelso
Offline
Joined: Jan 15 2009
Points: 0

kvm troubles with vlan switch
Posted January 15, 2009 - 5:40pm

Hello to all, i need help configuring a network virtual pc.
All PCs have debian SO.
I must connect a phisical PC with two virtuals pc to a switch. The switch have two vlan networks. in total there are three

nets (192.168.1.0,192.168.4.0,192.168.101.0)

http://www.imagegratis.com/free/uploads/9129ae315b.gif

The guest pcs must be like another pc conneted to the swith that are connecte to the three networks.
I have do a bridge called br0 in the eth0 of the host PC with ip address 192.168.1.10
In the guest01 PC i have configured eth0 with ip address 192.168.1.11 , and two vlans: eth0.4 with 192.168.4.11 and eth0.101

with 192.168.101.11, the guest02 is like guest01 but using 12 instead of 11.
The case is that those pcs can acces to the network 192.168.1.0 but can not access to the networks 192.168.4.0 and

192.168.101.0.
the etc/network/intefaces are the nexts
*******
hostPC
*******
auto br0
iface br0 inet static
address 192.168.1.10
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.1
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off

*******
guest01PC
*******
auto eth0
iface eth0 inet static
address 192.168.1.11
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.1

auto eth0.4
iface eth0 inet static
address 192.168.4.11
netmask 255.255.255.0
broadcast 192.4.1.255
network 192.168.4.0
gateway 192.168.4.1

auto eth0.101
iface eth0 inet static
address 192.168.101.11
netmask 255.255.255.0
broadcast 192.168.101.255
network 192.168.101.0
gateway 192.168.101.1

*******
guest02PC
*******
auto eth0
iface eth0 inet static
address 192.168.1.12
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.1

auto eth0.4
iface eth0 inet static
address 192.168.4.12
netmask 255.255.255.0
broadcast 192.4.1.255
network 192.168.4.0
gateway 192.168.4.1

auto eth0.101
iface eth0 inet static
address 192.168.101.12
netmask 255.255.255.0
broadcast 192.168.101.255
network 192.168.101.0
gateway 192.168.101.1

Anybody know how to do for that the guest PCs can i access to the another 2 vlan networks?
In the guest PC i have installed vlan program.

dcelso
Offline
Joined: Jan 15 2009
Points: 0
Hello again, Connecting a

Hello again,

Connecting a guest PC to a vlan cisco switch
In my case I have Debian in host and guest.
The switch have two vlan networks. in total there are three
nets (192.168.1.0,192.168.4.0,192.168.101.0)
I am using a tap interface for share the real interface.

The network configuration is
hostPC
*******
auto br0
iface br0 inet static
address 192.168.1.10
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.1
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off

*******
guestPC
*******
auto eth0
iface eth0 inet static
address 192.168.1.11
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.1

auto eth0.4
iface eth0 inet static
address 192.168.4.11
netmask 255.255.255.0
broadcast 192.4.1.255
network 192.168.4.0
gateway 192.168.4.1

auto eth0.101
iface eth0 inet static
address 192.168.101.11
netmask 255.255.255.0
broadcast 192.168.101.255
network 192.168.101.0
gateway 192.168.101.1

The running kvm have the parametters "-net nic -net tap,ifname=tap0"

The result is that the guestPC can not connet to the two vlan networks. It only can do ping to the PC connected to the network 192.168.1.0.

Trying the same configuration in VirtualBox it goes very well.

I think that the method that kvm use for share the interface is not a completely real share. Can be it because kvm uses a particular vlan = 0 in the default and causes conflicts with vlans of the switch.

There are any other method to avoid this restriction?

Anonymous
Well I haven't checked your

Well I haven't checked your configuration completely but I'm using a similar configuration. We've two vlan's configured on our cisco switches. vlan96 for the traffic to the loadbalancer and vlan104 for the traffic between all the hosts and databases.

All hosts have a br0 (vlan104) and br1 (vlan96) which in turn consists of two redundant links to the switches. Vlans are completely handled by the switches. There is no vlan configured in the host.

br0 is eth0 and br1 is eth1 in the guest system. As you can see here

-net nic,vlan=104,model=virtio,macaddr=$MACADDR_B
-net tap,vlan=104,ifname=tap.b.$KVMNAME,script=no
-net nic,vlan=96,model=virtio,macaddr=$MACADDR_F
-net tap,vlan=96,ifname=tap.f.$KVMNAME,script=no

I call the interfaces tap.b.$KVMNAME and tap.f.$KVMNAME (replace $KVMNAME with a name you like). I've created the interfaces with tunctl link this:

sudo tunctl -u kvm -t "tap.b.$KVMNAME"
sudo ifconfig "tap.b.$KVMNAME" 0.0.0.0 up
sudo brctl addif br0 "tap.b.$KVMNAME"

sudo tunctl -u kvm -t "tap.f.$KVMNAME"
sudo ifconfig "tap.f.$KVMNAME" 0.0.0.0 up
sudo brctl addif br1 "tap.f.$KVMNAME"

Before I realized that I need a vlan inside the KVM I saw traffic for br0 in br1 and vice versa. With the "vlan=..." options everything now works as expected.

And do not forget to give every interface a different MAC address.

Maybe this hints helps you to solve your problem.

Robert

Anonymous
Thanks for your response

I solved the trouble changing to kvm83 and changing the interface model to e1000. Virtio causes some trim buffer troubles.

However, I need have only one interface in the GuestPCs, because those will run custom applitations that can be change the vlan configurations and I unknown "a priori" how vlans there will be.

Now I have another trouble when I create a vlan with vconfig in the HostPC the vlans in the GuestPCs stop working.

I have open a bug in the kvm sourceforge traker. You can visit it for more information.

If you known how to solve this new trouble I will thank to you again.

http://sourceforge.net/tracker2/?func=detail&aid=2528121&group_id=180599...

Anonymous (not verified)
Try away this effective court

Try away this effective court to facilitate do a uncomplicated undo cell phone search so whilst to reverse phone stumble on out who is behind with the purpose of telephone number. In addition to you can as well run through this telephone number search so while to accomplish a telephone search with reference to that liar. In addition to still by a repeal search be capable of carry out the overturn cell phone method the preeminent thing you can forever do condition you deem regarding it at present.

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.