Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [2349:130522]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-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
COMMIT

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
add comment

2 Answers 2

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
add comment

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
add comment

Your Answer

 
discard

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.