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'm on an Ubuntu server running Apache2. I would like to protect myself against (d)dos and syn flood attacks and therefore try to limit the number of parallel connections per client IP.

I've heard iptables can do this job, and I've had a look at different commands. I would like to hear your opinion. As far as I know, the following commands both block clients for 60 seconds, if they make more than 100 concurrent/parallel connections to port 80. Is that correct, and is there any difference between the two?

Command 1

iptables -A INPUT -p tcp -m recent --rcheck --seconds 60 -j REJECT

iptables -A INPUT -p tcp --dport 80 -m connlimit --connlimit-above 100 -m recent --set -j REJECT

Command 2

iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --set

iptables -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --update --seconds 60 --hitcount 100 -j REJECT

My setup

I'm running multiple Wordpress sites on my server. I think 100 concurrent connections per client should be enough - anybody exceeding this should be blocked. Is this a reasonable limit?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You may want to reconsider putting a reverse proxy (Lighttpd, Nginx, Varnish et. al.) in front of the Apache to ease the load on it in case of an attack.

share|improve this answer
    
Thanks for the advice. Much appreciated! Do you have any experience with Nginx? I've set it up in front of Apache and have faced a couple of challenges: 1) I currently have 10 vhost files for Apache. Do I have to duplicate all of them for Nginx? 2) I'm running a benchmark test on a file (test.php). If I change the content of the file, these changes are not reflected when viewing through Nginx. I know: the entire purpose of Nginx is caching static files, but shouldn't it purge cache when the file has changed? Cheers! –  sqren Jul 11 '11 at 12:48
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.