LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   VDE and KVM -- guests and host all on same subnet (https://www.linuxquestions.org/questions/slackware-14/vde-and-kvm-guests-and-host-all-on-same-subnet-946008/)

kfritz 05-20-2012 10:25 AM

VDE and KVM -- guests and host all on same subnet
 
I've been using AlienBOB's excellent writeup for VDE configuration, and it works great, but I'd like the guests on the same subnet as the host, rather than on a separate subnet and nat'd. So far I've tried:

1. Bridging tap0 and eth0. This gets my guest on the subnet of eth0, but I cannot get from host to guest or any other PC on lan to my host.

2. Adding a second tap (tap1) using slackbuild tunctl, to add to the bridge. Cannot get tap1 running.

3. Specifying multiple tap interfaces in vde_switch. That just doesn't seem to work at all.

Does anyone have a similar setup working using vde?

allend 05-20-2012 11:17 AM

As I understand it, VDE requires a tap interface. As this is a virtual network interface device, then it needs to be on a separate subnet to your physical network interface, akin to having two physical network interface devices.
Quote:

1. Bridging tap0 and eth0. This gets my guest on the subnet of eth0, but I cannot get from host to guest or any other PC on lan to my host.
This is what I do, but I have no problems with host/guest/otherPC communications. Do you have DNSMasq setup correctly? Can you communicate by specifying IP addresses?

kfritz 05-20-2012 12:45 PM

Let me be more specific...

My "real" LAN is 192.168.1.x, and eth0 is plugged into this. If I configure VDE with a tap interface of 172.16.1.1, and run DNSMasq, turn on IP forwarding, turn on NAT or not, it all works just fine. However, I need to have some of my guests on the 192.168.1.x network, because the apps I'm testing want local broadcast and discovery with some real devices on this network.

I'm trying to just bridge the vde switch to my real lan. Is this possible?

Alien Bob 05-20-2012 12:59 PM

I use a modification to rc.inet1 and rc.inet1.conf which allows for the configuration of a network bridge of your ethernet card and the tap interface used by VDE.

See http://connie.slackware.com/~alien/rc_scripts/bridging/ for the patch, example use inside rc.inet1.conf can be found there as well.
My own server where I run several VM's in parallel I have the following lines in my rc.inet1.conf - all it does at boot is to setup a bridge and add my eth0 network interface to the bridge. The tap interface does not get added until later when it is actually needed. You see that I commented out the eth0 configuration:
Code:

# Config information for eth0:
#IPADDR[0]="192.168.0.1"
#NETMASK[0]="255.255.255.0"
#USE_DHCP[0]=""
#DHCP_HOSTNAME[0]=""

# Config information for br0:
IFNAME[1]="br0"
BRNICS[1]="eth0"
IPADDR[1]="192.168.0.1"
NETMASK[1]="255.255.255.0"
USE_DHCP[1]=""
DHCP_HOSTNAME[1]=""

Setting up the tap interface so that multiple virtual machines can be made part of the network subnet of the host, is not hard. If you use my rc.vdenetwork script then that script takes care of adding the tap interface to the bridge when the vde_switch is created.

Add a call to my rc.vdenetwork script to rc.local like with these lines:

Code:

# Start the VDE network layer:
if [ -x /etc/rc.d/rc.vdenetwork ]; then
  echo "Starting VDE:  /etc/rc.d/rc.vdenetwork start"
  /etc/rc.d/rc.vdenetwork start
fi

Inside rc.vdenetwork, you have to set
Code:

NETWORKTYPE="bridge"
to use the bridge. Also, check the variable assignment TAP_DEV=kvm0 because that means the tap interface is going to be created with the name "kvm0" instead of the default "tap0".

When at last you start qemu, you have to add these parameters so that it uses this kvm0 tap interface (and your qemu package has to be compiled with vde support, like my own packages for qemu and qemu-kvm):

Code:

-net vde,sock=/var/run/kvm0.ctl,vlan=0 -net nic,model=virtio,vlan=0
Note that I specified a "virtio" network interface which gives the VM a very fast and efficient network card (supported in Slackware of course) but you can also use a normal network card (a "e1000" card is the default if you do not specify a name).

Eric

kfritz 05-20-2012 01:24 PM

Thanks, I'll give that patch a try later today ... my geeking time has expired for now.

So it looks like I need to bind the host IP address to the bridge interface? I did not try that...

kfritz 05-21-2012 10:18 PM

Eric: I followed your suggestions and everything works great. The only thing that didn't work for me was having the br0 interface pick up its address from DHCP -- it just timed out. That's OK, I had a permanent lease anyway, so I configured it static.

Thanks!!

Kent.


All times are GMT -5. The time now is 12:05 PM.