CentOS – Unable to Create Rule in IPTables to Open Port 80

centosiptables

I'm trying to open port 80 in iptables but am running into a couple issues. I am running CentOS 5.7.

First I tried to run this command:

iptables -I RH-Firewall-1-INPUT -p tcp -m tcp --dport 80 -j ACCEPT

But I received an error saying:

iptables: command not found

So I then ran the same command but with sbin added:

/sbin/iptables -I RH-Firewall-1-INPUT -p tcp -m tcp --dport 80 -j ACCEPT

Now I receive this error:

iptables: No chain/target/match by that name

Thanks in advance for any help that can be provided.

Best Answer

If you ran service iptables stop as someone suggested in the other Question you posted, then all iptables rules have been flushed, and there is no "RH-Firewall-1-INPUT" chain.

Assuming you're using the default firewall, do service iptables start. Run iptables -n --list as Zoredache suggests to verify that a chain named "RH-Firewall-1-INPUT" exists. If so, then the command you've shown should work. Run service iptables save afterwards to save it to the config file, so it will be there on the next reboot.

If there is no "RH-Firewall-1-INPUT" chain, the edit your question to show the results of the iptables -n --list, and we can proceed from there.