Enable ssh host to guest and guest internet on CentOS 7 guest using VirtualBox


Reg Mem

I have 2 CentOS 7 guests running in VirtualBox on an Ubuntu host.

I would like to be able to:

  1. Connect from host to guest using SSH
  2. Download/install packages from the Internet on the guest.

I currently have the following two virtual network interfaces

  • host only, mapped to "enp0s3" on the guest
  • NAT, mapped to "enp0s8" on the guest

My current configuration:

$ cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME=enp0s3
UUID=fcd0aa44-9ab7-42e6-a637-52c429727195
ONBOOT=yes
HWADDR=08:00:27:BE:DB:11
IPADDR=192.168.56.102
PREFIX=32
GATEWAY=192.168.56.1

and

$ cat /etc/sysconfig/network-scripts/ifcfg-enp0s8
HWADDR=08:00:27:A2:03:29
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s8
UUID=09acefe7-d513-48f6-b820-0988ac495e5e
ONBOOT=yes

Current route information:

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.56.1    0.0.0.0         UG    1024   0        0 enp0s3
10.0.3.0        0.0.0.0         255.255.255.0   U     0      0        0 enp0s8
192.168.56.1    0.0.0.0         255.255.255.255 UH    1024   0        0 enp0s3

At this point, I can SSH from the Ubuntu host to the CentOS guest, but I cannot successfully connect to the Internet:

$ wget https://github.com/antirez/redis/archive/3.0.0-rc6.tar.gz
Resolving github.com (github.com)... 192.30.252.130
Connecting to github.com (github.com)|192.30.252.130|:443...

Many other posts and examples suggested me to remove the default gateway from "enp0s3". If I remove the default gateway from "enp0s3", I cannot SSH to the CentOS guest from the Ubuntu host.

How can I make this work?

Reg Mem

So I finally got it working

I am missing a netmask value in the config

Host-only NIC enp0s3

TYPE=Ethernet
BOOTPROTO=static
NAME=enp0s3
UUID=71d4200e-199d-4d03-935d-6d2e88c41956
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.56.101
NETMASK=255.255.255.0

NAT invalid enp0s8

HWADDR=08:00:27:49:5A:6C
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s8
UUID=56cc4f81-d7a4-465a-badb-0b6120a0d62e
ONBOOT=yes

With the above values ​​it works the way I need it

  • ssh from host to guest
  • guest online
  • Database access from host to guest

Related


Uninstall VirtualBox guest on CentOS 7?

Hazman Firmanshah I am trying to uninstall VirtualBox guest for a CentOS virtual machine. what should I do? strength Open a terminal and enter the following command: cd /media cd VBOXADDITIONS_4.1.12_77218 sudo sh VBoxLinuxAdditions.run uninstall This shoul

Uninstall VirtualBox guest on CentOS 7?

Hazman Firmanshah I am trying to uninstall VirtualBox guest for a CentOS virtual machine. what should I do? strength Open a terminal and enter the following command: cd /media cd VBOXADDITIONS_4.1.12_77218 sudo sh VBoxLinuxAdditions.run uninstall This shoul

SSH from host Win7 to guest Fedora machine in VirtualBox

0fnt I'm using VirtualBox on Windows 7 to run Fedora 7 /sbin/service sshd status. When I execute /sbin/ifconfig, I get the following: eth0 link encap: ethernet HWaddr 08:00:27:CF:5A:0B inet address: 10.0.2.15 Bcast: 10.0.2.255 mask: 255.255.255.0 I do

SSH from host Win7 to guest Fedora machine in VirtualBox

0fnt I'm using VirtualBox on Windows 7 to run Fedora 7 /sbin/service sshd status. When I execute /sbin/ifconfig, I get the following: eth0 link encap: ethernet HWaddr 08:00:27:CF:5A:0B inet address: 10.0.2.15 Bcast: 10.0.2.255 mask: 255.255.255.0 I do

SSH from host Win7 to guest Fedora machine in VirtualBox

0fnt I'm using VirtualBox on Windows 7 to run Fedora 7 /sbin/service sshd status. When I execute /sbin/ifconfig, I get the following: eth0 link encap: ethernet HWaddr 08:00:27:CF:5A:0B inet address: 10.0.2.15 Bcast: 10.0.2.255 mask: 255.255.255.0 I do

Unable to mount VirtualBox Guest Additions as guest (Win7 host)

Michael Goldstein Unable to mountI keep getting this error dialog with error E_FAIL (0x80004005) when trying to mount Guest Additions : I tried "Force Uninstall", but that just closes the dialog without taking any action. If I then try to install the guest add

Unable to mount VirtualBox Guest Additions as guest (Win7 host)

Michael Goldstein Unable to mountI keep getting this error dialog with error E_FAIL (0x80004005) when trying to mount Guest Additions : I tried "Force Uninstall", but that just closes the dialog without taking any action. If you then try to install the guest a

Unable to mount VirtualBox Guest Additions as guest (Win7 host)

Michael Goldstein Unable to mountI keep getting this error dialog with error E_FAIL (0x80004005) when trying to mount Guest Additions : I tried "Force Uninstall", but that just closes the dialog without taking any action. If you then try to install the guest a

Unable to mount VirtualBox Guest Additions as guest (Win7 host)

Michael Goldstein Unable to mountI keep getting this error dialog with error E_FAIL (0x80004005) when trying to mount Guest Additions : I tried "Force Uninstall", but that just closes the dialog without taking any action. If I then try to install the guest add

SSH to Ubuntu host from Ubuntu VirtualBox guest?

Mountain X I want to SSH into my host (Kubuntu 12.04 64bit) from a VirtualBox guest running 32bit Ubuntu 12.04. The host has the latest VirtualBox from the Ubuntu repositories (4.1.12). The guest is a preconfigured VM that I downloaded from VirtualBoxImages.co

SSH to Ubuntu host from Ubuntu VirtualBox guest?

Mountain X I want to SSH into my host (Kubuntu 12.04 64bit) from a VirtualBox guest running 32bit Ubuntu 12.04. The host has the latest VirtualBox from the Ubuntu repositories (4.1.12). The guest is a preconfigured VM that I downloaded from VirtualBoxImages.co

VirtualBox guest as Nginx host

Massin I installed VirtualBox 4.3.12 with Fedora 20 and nginx 1.4.7. The machine has a bridged network interface and can be pinged in two ways: from the host (Windows 7) using ping 192.168.0.15(IP address of the virtual machine) and from the guest machine ping

Host and guest are shared in Virtualbox

Mascarpone cheese Since Ubuntu 11.10 uses a new kernel, it's hard to get decent support for virtualization. VirtualBox doesn't support guest additions for ubuntu 11.10, so I definitely can't copy back and forth between the ubuntu desktop and windows, and FreeB

VirtualBox guest as Nginx host

Massin I installed VirtualBox 4.3.12 with Fedora 20 and nginx 1.4.7. The machine has a bridged network interface and can be pinged in two ways: from the host (Windows 7) using ping 192.168.0.15(IP address of the virtual machine) and from the guest machine ping

How to install VirtualBox guest for CentOS 7?

Chloe how? It gives an error. [vagrant@localhost mnt]$ sudo ./VBoxLinuxAdditions.run Verifying archive integrity... All good. Uncompressing VirtualBox 5.1.16 Guest Additions for Linux........... VirtualBox Guest Additions installer Removing installed version 5

How to install VirtualBox guest for CentOS 7?

Chloe how? It gives an error. [vagrant@localhost mnt]$ sudo ./VBoxLinuxAdditions.run Verifying archive integrity... All good. Uncompressing VirtualBox 5.1.16 Guest Additions for Linux........... VirtualBox Guest Additions installer Removing installed version 5

Add Virtualbox guest on Ubuntu host and Manjaro guest

Farzad I have installed Manjaro in a guest VM on an Ubuntu 18.10 host, but I cannot use the guest additions in the Manjaro guest. I have installed the kernel 5.1.1-2in Manjaro and the output uname -ris: 5.1.1-2-MANJARO Then I tried to install virtualbox-guest

Add Virtualbox guest on Ubuntu host and Manjaro guest

Farzad I have installed Manjaro in a guest VM on an Ubuntu 18.10 host, but I cannot use the guest additions in the Manjaro guest. I have installed the kernel 5.1.1-2in Manjaro and the output uname -ris: 5.1.1-2-MANJARO Then I tried to install virtualbox-guest

Access site on host from guest using VirtualBox?

Gilchaz I'm running VirtualBox on a Mac (host) and the VM used is Windows 7 (guest). VirtualBox is set up to use a NATnetwork adapter and has internet access (google, msn, etc.) fine, but I'm hosting a site on a Mac (host) so I can't access it from the VM. The

Access site on host from guest using VirtualBox?

Gilchaz I'm running VirtualBox on a Mac (host) and the VM used is Windows 7 (guest). VirtualBox is set up to use a NATnetwork adapter and has internet access (google, msn, etc.) fine, but I'm hosting a site on a Mac (host) so I can't access it from the VM. The

The host cannot SSH the guest, but the guest can

Samaras This is a follow-up question from: Getting virtualbox to get a different IP address than my laptop . I ended up using these files /etc/hostson both my laptop (host) running Ubuntu 14.04 and my virtual machine (guest) running Ubuntu 14.04 : 127.0.0.1

The host cannot SSH the guest, but the guest can

Samaras This is a follow-up question from: Getting virtualbox to get a different IP address than my laptop . I ended up using these files /etc/hostson both my laptop (host) running Ubuntu 14.04 and my virtual machine (guest) running Ubuntu 14.04 : 127.0.0.1

How to SSH from host to guest using QEMU?

Jobin How to setup ssh from host to guest using qemu? When booting a virtual machine, you can use port redirection without any special parameters as follows: /usr/bin/qemu-system-x86_64 -hda ubuntu1204 -m 512 -redir tcp:7777::8001 However, when I try to boot