Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
what does your /etc/sysconfig/iptables file look like ? – Zypher Feb 16 '12 at 18:11
Do you already have iptables rules set? What do you see if you do an iptables -n --list? – Zoredache Feb 16 '12 at 18:12
Your initial problem is caused because /sbin is not in your path - and this can often happen if you are not root or if you sudo root without changing the PATH variable to include /sbin (and /usr/sbin). – Mei Feb 16 '12 at 18:13
What makes you think a chain named "RH-Firewall-1-INPUT" should exist? What does the output of iptables -L look like? – larsks Feb 16 '12 at 18:16
up vote 3 down vote accepted

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.

share|improve this answer
This was exactly what I needed to do, thanks for your help. – Windows Ninja Feb 16 '12 at 18:36

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:

Hope this helps

share|improve this answer
This is a great site, going to read through it carefully. Thanks for your help. – Windows Ninja Feb 16 '12 at 18:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.