LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   Host to Guest and vice versa networking (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/host-to-guest-and-vice-versa-networking-763187/)

opaltoad 10-20-2009 08:56 AM

Host to Guest and vice versa networking
 
How do i connect to my guests from the host...or anywhere else for that matter?

I've started running KVM on my PC, which has 2 NICs installed.
The guest is bridged, using virtio, to eth0 and the host is set to use eth1 for normal internet activity.

So far everything seems to be working correctly, i.e they can all connect to the internet. Now I've disabled the firewalls on the guests and allowed all connections for eth0 on the host but I can't/don't know how to connect to the services running on them(sendmail and apache). Netstat on the guests show that the correct ports are open.

Am I meant to be connecting to the IP assigned to eth0?

manwichmakesameal 10-20-2009 02:08 PM

I use VirtualBox, so I'm not sure how much applies to you but here goes. I have 2 nic's on my desktop. One for the host system, one for the VM's. I have a script (that I don't have access to right now) that runs at boot and creates a bridge adapter. I know I probably don't need to do that but, oh well. So I end up with 3 interfaces: eth0, eth1 and br0. In VBox, I have my VM's use the br0 adapter and my network is set up with static ip's. Now, my VM's can access anything on the network just like any other machine and my host machine can access all the vm services as well.

Code:

#!/bin/sh

# This script is for starting our bridge interface for our
# virtual machines

/sbin/modprobe tun

# First, set up eth1
ifconfig eth1 up
ifconfig eth1 0.0.0.0

# Create our bridge and add the interfaces
brctl addbr br0
brctl addif br0 eth1

# Bring interface br0 up
ifconfig br0 up

# Create tun devices for vbox and add them to the bridge
echo "Creating VirtualBox tun devices..."
VBoxAddIF vbox0 $USER br0 &>/dev/null


opaltoad 10-21-2009 08:10 AM

I haven't had a chance to check my initialization scripts yet, but it sounds like our setups are similar, as I also get the 3rd interface, virbr0.

What I can't get my head around is:
Wireshark shows that all outgoing traffic from the guest goes through 192.168.0.10 on the LAN(which is assigned to eth0). Incoming traffic does the same, but only because the connection was initiated by the guest.
So if I tried to open a connection to 192.168.0.10 on port 80 from another PC on the network, it tries to connect to the host and not the guest which is the one running the apache service.
Is this where tun/tap comes into play?

manwichmakesameal 10-22-2009 04:11 PM

I am by no means an expert, but I think that is what the tun module is for. Check here. It seems to be kind of old, but should still apply.


All times are GMT -5. The time now is 03:53 PM.