0

I need to be able to configure my virtualbox machine to be accessed from the host (my laptop) without the routing through the Internet. Right now I have a virtualbox machine with hostonly adapter vboxnet0 and NAT. The virtual machine has a static IP address 192.168.56.50. I want all requests from the host to IP address 192.168.56.50 to be directed straight to the virtualbox machine (with the IP address 192.168.56.50). I can't use bridged interface because the Internet is limited on the host and not always persist.

4
  • You might want to look at this article - - 2buntu.com/articles/1513/… – Anaksunaman Mar 12 '18 at 2:58
  • It doesn't work in my case. I think my routes are not configured properly on the host or virtualbox isn't configured properly – Oleksandr Mar 12 '18 at 19:27
  • What is the IP address of the host? From your post it sounds like both the host and VM have the same IP address. – essjae Mar 14 '18 at 1:18
  • The host has the IP 192.168.56.1 – Oleksandr Mar 14 '18 at 8:11
0

The problem was that I didn't have a proper routing on the virtual machine. My first interface (host-only) has a configuration:
/etc/sysconfig/network-scripts/ifcfg-eth0:

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"
IPV6_PRIVACY="no"
IPADDR=192.168.56.50
NETMASK=255.255.255.0
PEERDNS=no
DNS1=8.8.8.8
DNS2=8.8.4.4
ZONE=public

My second interface (NAT) has a configuration:
/etc/sysconfig/network-scripts/ifcfg-eth1:

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth1
DEVICE=eth1
ONBOOT=yes
PEERDNS=no

So, my VM had the Internet, but I couldn't connect to the VM from the host. After that I tried to add GATEWAY=192.168.56.1 to the eth0 and it fixed the problem with the host (I could connect to the VM from the host) but I didn't have the Internet. That is why I removed GATEWAY=192.168.56.1 from eth0 and added a manual route for the host-only interface.
/etc/sysconfig/network-scripts/route-eth0:

192.168.56.0/24 via 192.168.56.1 dev eth0

After reboot, I could connect to the VM from the host and my VM had the Internet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.