Virtual Box Connect to HTTP Server on Guest OS

Problem

I have a Guest OS on Virtual Box, running on Ubuntu based Host OS. I can ping and ssh into my CentOS 7 Guest OS from the host after using the Host Only Networking option on Virtual Box.

The problem came in when I tried reaching the Guest OS’s IP on the Host OS web browser. I’d get this error:

Host OS Web Browser
Host OS Web Browser

Telnet from the host to the Guest IP gave the following error:

telnet 192.168.56.102 80 telnet: Unable to connect to remote host: No route to host
Telnet Result of Host-to-Guest

Troubleshooting

  • Check if port is Open and if firewall is running on Guest OS
check-port-firewall-on-guest-OS
check if-port is open-firewall-running-on-guest-OS
  • Tried to telnet port from Guest OS
telnet-from-guestOS
telnet-from-guestOS successful
  • Tried to ping Guest IP from the Host IP and this was successful:
ping-host-to-guest
ping-host-to-guest

Solution

After some doodling, found this pointer.

Starting with CentOS and RHEL 7, firewall rule settings are managed by firewalld service daemon. A command-line client called firewall-cmd can talk to this deamon to update firewall rules permanently.

service firewalld status
centos firewalld was running

So after stopping firewalld, I was able to telnet to port 80 and also get a response on the web browser:

service firewalld stop
stop-firewalld
telnet-host-to-guest successful
telnet-host-to-guest successful
host-web-browser
host-web-browser

NB:// Another alternative to stopping the firewall, is open up the http service/port on the firewall. This can be achieved as explained here.

Resources

Virtualbox: How to access web server on guest OS from the host OS?

A few ways to configure Linux firewalld

RHEL 7 / CentOS 7: How to get started with Firewalld

RHEL7: How to get started with Firewalld.

How to open a port in the firewall on CentOS or RHEL

One thought on “Virtual Box Connect to HTTP Server on Guest OS

Leave a comment