Centos – Fresh CentOS install with Apache in VirtualBox: Host OS can’t access the test page

apache-2.4centosvirtualbox

Context: I just got a job as a sysadmin and my employers are quite aware that I'm new to this scene so they're having someone show me the ropes. Her first task for me was to set up a VM with CentOS.

I've set up CentOS on my VM and I installed Apache without incident. When I tried to access it using the browser on the host via IP address, it says that it took too long to respond (using Google Chrome).

I've set network adapter of the VM to a bridged adapter and I'm not using the loopback address for this. I tried using

curl myipaddress

And it shows the HTML just fine. I tried pinging the VM's ip address and it replies fine.

I tried ruling out iptables. What I got when I tried to stop it:

Failed to stop iptables.service: Unit iptables.service not loaded.

Which upon further checking implies that iptables isn't installed.

I tried checking the status of the service with

sudo service httpd status 

And it's apparently working fine.

I basically left the settings at their default so I'm not sure what I'm overlooking. It looks like a misconfiguration but I'm not sure exactly what.

Best Answer

I guess you need to open the ports through firewalld (the default firewall in Centos 7).

You can try, just for testing:

firewall-cmd --permanent --add-port=80/tcp

To see what active zones you have, you can use:

firewall-cmd --get-active-zones

And then, a port (i.e. tcp 80 for http) can be opened, let's say for the zone 'public':

firewall-cmd --permanent --zone=public --add-port=80/tcp 

The reload firewalld:

firewall-cmd --reload

The option permanent makes the rule permanent, even if the service or server restarts. You will need to run the commands as root or use sudo.

Related Topic