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 am trying to open some ports on a centos box for the first time and I have edited the iptables file, but when I run nmap from the host on loopback or run it from another machine the ports do not seem to be open. Here is my iptables file:

:OUTPUT ACCEPT [2349:130522]
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1883 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8161 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 61616 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5672 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 61613 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited

What am I doing wrong?

share|improve this question
When you send something to one, do you get ICMP host prohibited, or just nothing? If it's dropped chances are your machine just isn't listening on those ports. – Falcon Momot Jun 3 '13 at 18:41
up vote 4 down vote accepted

Allow traffic to a port doesn't make it open.

You must have a service listening on this port, so that you can send some data to this port, wait for respone from your service, then you will "see" it open.

You can use netcat to creat a port open, i.e:

In Server: nc -l -p 1234
In Client: echo "Hello" | nc <IP Server> 1234
share|improve this answer

If nothing's listening on the port, it won't show up on nmap. You could try using something like socat to emulate a listening program, or make a program listen on the port.

share|improve this answer

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.