Set Firewall To Allow Access To TCP/80 Over Network From A CentOS VM

Continuing from the last two posts I was able to get the network working and set the static IP but I wasn’t able to access web server from other nodes on my network.

The two simple ways to check if your web server is accessible from your network is as follows.

  1. Python is universally installed on all Linux systems. We could use SimpleHTTPServer module for Python to check the web server. You can spun off a Python web server by running the following command.
    python -m SimpleHTTPServer 8000

Check your server at http://vm-ip-address:8000

  1. You could also install Apache web server and run it using systemd.
    yum install httpd
    systemctl start httpd

Again go to your machine’s IP address http://vm-ip-address

Now some of you might notice that server is isn’t working. At least it didn’t work on my system. CentOS 7’s firewall was blocking access to 80/tcp. You can create a rule for it as follows.

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

For more information please read man firewall-cmd.

Now you can access the web server on any node in your network.