LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   accessing a KVM guest from outside the host (https://www.linuxquestions.org/questions/linux-general-1/accessing-a-kvm-guest-from-outside-the-host-4175459824/)

rootaccess 04-27-2013 07:21 PM

accessing a KVM guest from outside the host
 
I have two machines, a laptop on 192.168.1.82 and a desktop which is the host for KVM setup on 192.168.1.98. There is 1 guest running which is a centos minimal addressed at 192.168.122.100. All OS's are centos here.

I'm trying to ssh from the laptop (which has no connection to the host whatsoever besides being on the same subnet) to the KVM guest at 192.168.122.100. There already is a default bridge created on the host machine of course. Its called virbr0 and the subnet is 192.168.122.0

I tried to ssh into the guest from the laptop and fail

[03:10 PM][root@ibm network-scripts]# ssh root@192.168.122.100
ssh: connect to host 192.168.122.100 port 22: No route to host

I tried to create a bridge on the laptop machine. Here are the 2 files in /etc/sysconfig/network-scripts that I have edited to reflect that. I did name this bridge br0 instead of virbr0 because I dont think it really matters

this is ifcfg-br0
DEVICE=br0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Bridge

And ifcfg-eth0
DEVICE=eth0
IPADDR=192.168.1.82
NETMASK=255.255.255.0
GATEWAY=192.168.1.254
ONBOOT=yes
NM_CONTROLLED=no
DNS1=192.168.1.254
BRIDGE=br0

This is the output after restarting the network

[05:15 PM][root@ibm network-scripts]# service network restart
Shutting down interface br0: [ OK ]
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
Bringing up interface br0:
Determining IP information for br0... done.
[ OK ]


[05:18 PM][root@ibm network-scripts]# ssh root@192.168.122.100
ssh: connect to host 192.168.122.100 port 22: No route to host

Am I supposed to setup masquerading and ip forwarding on the host machine to allow the network to traverse outside the host? I guess I just want to understand HOW I am supposed to get in from outside the host. Thanks.

marafa 04-27-2013 08:37 PM

you need to research macvtap.

you will also need to understand whether you want 1 or 2 nics.
1 for the guest to be accessible from the host but not the outside network and
1 for the guest to be accessible from the outside network but not the host (via the network coz u can reach it via console)

rootaccess 04-27-2013 11:29 PM

Thanks but I followed this tutorial and it helped immensely
http://www.techotopia.com/index.php/...idge_Interface

Apparently, by default, VMs are created under a NAT bridge that is only accessible via the host. The host is basically set up with virbr0 which is the bridge defining access to the VMs. In this configuration, VMs are not accessible from outside the host. What has to be done is a regular bridge set up on the host machine. The VMs themselves also need to be configured to bridge under the newly created bridge on the host machine and NOT the default NAT bridge known as virbr0 and set up with the default 192.168.122.1 network.


All times are GMT -5. The time now is 04:36 AM.