Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm looking to use iptables to help limit denial of service attacks to my webserver. I'm no iptables expert, so I'd like the input of some experts on my idea. I'm thinking about the following. Will it work? Are there improvements to be had or a better idea generally? The idea is to block IPs having 50 or more hits per second.
Code:
/usr/sbin/iptables -N webdrop
/usr/sbin/iptables -A webdrop -j LOG --log-level 6 --log-prefix "Web DoS attempt "
/usr/sbin/iptables -A webdrop -j DROP
/usr/sbin/iptables -N webcount
/usr/sbin/iptables -A webcount -m recent --set
/usr/sbin/iptables -A webcount -m recent --rcheck --hitcount 50 -j webdrop
/usr/sbin/iptables -A webcount -j RETURN
/usr/sbin/iptables -A INPUT -p tcp --syn -m multiport --dports 80,443 -i eth0 -j webcount
/usr/sbin/iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 3 -i eth0 -m multiport --dports 22,443 -j ACCEPT
The iptables rules looks fine but may be other people have better suggestions, on the other and if you have an apache server behind you can have a look to http://dominia.org/djao/limitipconn.html, im sure that nginx have something similar.
For have a good approach to DoS attacks is to act at network layer(iptables) and at application layer (mod on apache or whatever).
The iptables rules looks fine but may be other people have better suggestions, on the other and if you have an apache server behind you can have a look to http://dominia.org/djao/limitipconn.html, im sure that nginx have something similar.
For have a good approach to DoS attacks is to act at network layer(iptables) and at application layer (mod on apache or whatever).
Thanks - I'm trying the mod_limitipconn now, although I'll have to contrive to get more than 10 simultaneous connections going.
I'm still looking for some feedback on the iptables rules before I try those.
--update: Updates the recent counter in webcount. --seconds: This is the timer for the recent counter in webcount.
So in other words when a packet comes in for ports 80 or 443 they go to the webcount chain. This chain then looks at the counters in webcount for the ip address if it is not there it is added by update. If it is there the last time is updated with the present time and the the count is checked against the timer seconds. If the hit count is above hitcount and the time the ip was last seen is under seconds the rule is applied.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.