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

1 Answer 1

vi /etc/sysconfig/iptables

then add:

-A INPUT -i eth0 -s 100.101.102.103/32 -p tcp -m tcp --dport 22 -m state --state NEW,RELATED,ESTABLISHED -m comment --comment "SSH inbound" -j ACCEPT 
-A INPUT -j DROP
-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 100.101.102.103 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

 
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.