Unable to Create Rule in IPTables to Open Port 80
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.
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.
run "iptables -nvL", see what the correct name of your chains are then run something like this to append the rule to the chain:
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
Here's a great link that I used to learn IPtables: https://help.ubuntu.com/community/IptablesHowTo
Hope this helps