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 a connection on a machine both ways. That is I am trying to open say the port 8001 and I did this.

iptables -A INPUT -p tcp --dport 8001 -j ACCEPT

Now how to configure so the server lets the outgoing packets generated by the program listening on 8001.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

iptables -A OUTPUT -p tcp --sport 8001 -j ACCEPT

You can also use the connection tracking take care of it, with something like iptables -A OUTPUT -m state --state ESTABLISHED -j ACCEPT -- some people have preferences one way or the other, use whichever one suits you better.

share|improve this answer
    
I need to specify a protocol after -p right. Because it gives me an error. But I went ahed and put tcp like this. iptables -A OUTPUT -p tcp --sport 8001 -j ACCEPT After configuring with the above command and the previous one I mentioned, I did nmap localhost - but I do not see 8001 listed in there. How to check if things worked (before actually waiting for other programs to start using 8001) –  Senthil Dec 18 '09 at 2:01
    
Yeah, need a protocol for -p. Answer updated. I normally test TCP ports with netcat and tcpdump. –  womble Dec 18 '09 at 2:11
add comment

Your Answer

 
discard

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