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 set-up iptables so it will only allow incoming connections on ports I specify.

I managed to get it working however it seems I somehow managed to break outgoing connections in the process.

Both NS look-ups and pings seem to fail, and probably everything else too.

Current rules:

Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:ssh

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

So how can I make this work, while still allowing outgoing connections?

share|improve this question
up vote 3 down vote accepted

Try: iptables -A INPUT -p TCP -m state --state ESTABLISHED,RELATED -j ACCEPT

share|improve this answer
I agree, except the ,RELATED, which isn't needed just to allow return-half packets, though it seems to be cargo-culted in by a lot of people. Depending on what kernel modules are loaded, RELATED can let in a lot more traffic than you might like, and I would advise against using it without good reason to do so. – MadHatter Mar 4 '11 at 14:06
Yeah, this solved it, thanks a lot. – Not Available Mar 4 '11 at 18:31

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.