Networking – How to SSH from a VM to a Private Server via Ethernet

centosnetworkingsshvirtual machinevirtualbox

A devbox has Windows 8.1 as the host OS running VirtualBox and a virtual machine with CentOS 7 for development. The devbox is connected to a CentOS 7 development server through an Ethernet cable. The development server is not connected to the Internet, or to any other computer.

The devbox Windows 8.1 host OS is able to SSH to the development server using PuTTY after making the config changes described in this other post. However, the CentOS 7 virtual machine inside the devbox is not able to make SSH connections to the development server.

In the devbox virtual machine, when I type

cd /etc/sysconfig/network-scripts

And then type:

ls ifcfg-*

The terminal prints out ifcfg-lo.

When I next type:

nano ifcfg-lo

The terminal shows:

DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
BROADCAST=127.255.255.255
ONBOOT=yes
NAME=loopback

However, I hesitate to make the other changes shown in the other posting because the devbox virtual machine needs to retain the ability to ssh over the Internet also.

What changes need to be made in the devbox to allow the CentOS 7 VM to SSH into the development server?

Note that the virtual machine on the devbox is able to SSH to remote servers over the Internet. So the current problem is just getting it to know how to connect to the local Ethernet development server when a user types ssh username@192.168.100.2.

Best Answer

My suspicion is that on Oracle VirtualBox the networking is set to 'NAT'. This would explain why you can SSH to the Internet as the Windows 8.1 host NATs the guest's IP addresses for you and sends them out on the hosts external facing interface (which I assume you have, but you haven't mentioned).

Change the networking on the guest to 'Bridge' and connect that bridge to the ethernet device that connects to the CentOS dev server. Next, change the IP address of the VM (using the instructions in that linked post) to one within the range used by Ethernet network such as 192.168.100.3.

You could use the host IP address as the default gateway of the VM to save changing it again if you decide to use Internet Connection Sharing on the host to allow the CentOS machines to access the Internet.

Related Question