Iptables – Basic Iptables question (Open connection both ways)

firewalliptablesport

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.

Best Answer

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.

Related Topic