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 use this code to protect my ssh.

*filter
-N SSH_CHECK
-A INPUT -p tcp --dport 22 -m state --state NEW -j SSH_CHECK
-A SSH_CHECK -s xxx.xxx.xxx.xxx/32 -j ACCEPT
-A SSH_CHECK -m recent --set --name SSH
-A SSH_CHECK -m recent --update --seconds 900 --hitcount 2 --name SSH -j DROP
-A INPUT -p tcp --dport 80 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
-A INPUT -p tcp --dport 25 -j DROP
-A INPUT -p udp --dport 25 -j DROP
COMMIT

How can I add port 21 to this list?

If I use

-A INPUT -p tcp --dport 21 -m state --state NEW -j SSH_CHECK

Is it same as using port 22?

share|improve this question
add comment

1 Answer 1

You can rate-limit new FTP connections from a host using the same method you're rate limiting FTP. I'd create another chain (something like FTP_CHECK rather than SSH_CHECK) and you'll want to use another list (say FTP rather than SSH) to keep the incoming FTP host addresses separate from SSH addresses. Something like:

-A INPUT -p tcp --dport 21 -m state --state NEW -j FTP_CHECK
-A FTP_CHECK -s xxx.xxx.xxx.xxx/32 -j ACCEPT
-A FTP_CHECK -m recent --set --name FTP
-A FTP_CHECK -m recent --update --seconds 900 --hitcount 2 --name FTP -j DROP

Two FTP connections in 900 seconds is a little bit strict, though, in my opinion. I'd open that up a little bit more or legitimate users may find that, should they get disconnected, they won't be able to reconnect. Tune to suit your needs.

share|improve this answer
add comment

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.