Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 want iptables rules that let a server allow incoming ssh from a specific host and at the same time this server can connect ssh on any destination, then block any other in/out traffic

Thanks in advance,

share|improve this question

vi /etc/sysconfig/iptables

then add:

-A INPUT -i eth0 -s -p tcp -m tcp --dport 22 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "SSH inbound" -j ACCEPT 
-A OUTPUT -o eth0 -p tcp --sport 22 -m state --state RELATED,ESTABLISHED -m comment --comment "SSH outbound" -j ACCEPT
-A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "General SSH outbound" -j ACCEPT

Replace with any IP address you need

share|improve this answer
Default deny policies might be useful at all. Nothing here does any dropping. – Falcon Momot Oct 2 '13 at 9:47
Alan, I think these rules don't effect as you drop nothing. – Tariq Oct 2 '13 at 10:21
I was trying to be as relevant as can be. – Alon Kogan Oct 6 '13 at 14:23

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.