Accessing centos apache/httpd from vbox host

Posted by alexmoreno on Tue, 04/12/2012 - 01:01

This is the scenario. You installed vbox in your Mac, windows or Linux computer. Then you´ve installed Centos or Red Hat (or any other Red Hat flavor) in this virtual box.

Next step, installed httpd (apache2) and... even it is running and httpd status confirms it with a "running" message, it cannot be accesible from your host machine.

The problem is on iptables. Red Hat by default denies access to this machine from other (external) machines. Solution? Very easy, open iptables file:

vim /etc/sysconfig/iptables

(vim is my favourite editor for a loooong long time)

Look for this line:

-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT

and after that, add this one:

-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT

Restart your services and everything done:

service iptables restart

Thank to