iptables HTTP Flood pro IP

FreeBSD, Gentoo, openSUSE, CentOS, Ubuntu, Debian
a-n
Posts: 145
Joined: 2004-05-10 10:15
 

iptables HTTP Flood pro IP

Post by a-n »

Hallo,

ich habe hier eine iptables Regel die irgendwie nicht richtig ist.

Code: Select all

#    iptables -N SYN
#    iptables -A INPUT -p tcp --syn --dport 80 -j SYN
#    iptables -A SYN -m limit --limit 25/s --limit-burst 4 -j RETURN
#    iptables -A SYN -j DROP

Leider blockt diese Regel alle IPs wenn ein SYN von 25/s kommt. Wie kann man die Regel umschreiben das nur die IP gedropt wird die sozusagen mehr als 25/s TCP Pakete sendet?

Vielen Dank!
a-n
Posts: 145
Joined: 2004-05-10 10:15
 

Re: iptables HTTP Flood pro IP

Post by a-n »

Niemand eine Idee oder ne Anregung?
a-n
Posts: 145
Joined: 2004-05-10 10:15
 

Re: iptables HTTP Flood pro IP

Post by a-n »

Hi,

habe mir ipt_recent angeschaut, aber nicht wirklich fundig geworden die einen Dienst pro IP begrenzt.

Habe nun dies hier gefunden ...

http://netfilter.org/documentation/HOWT ... html#ss3.3

Muss nur noch rausbekommen wo ich den Kernel-Patch finde, und dann einsetzen. Werde dann ggf. berichten.

Danke, dennoch!
hornox
Posts: 139
Joined: 2005-09-22 23:09
 

Re: iptables HTTP Flood pro IP

Post by hornox »

habe mir ipt_recent angeschaut, aber nicht wirklich fundig geworden die einen Dienst pro IP begrenzt.
Wäre ja auch irgendwie untypisch wenn sowas nicht Modular aufgebaut wäre. Ipt_recent erstellt nur Listen mit IPs und Zugriffszeiten und kann neue IP Packete damit vergleichen; für das weiterverarbeiten bzw weitere testen der gefundenen IP Packete ist ein anderes Modul oder das Hauptprogramm zuständig.

http://www.debian-administration.org/articles/187
Das ist doch (mit angepassten Ports, Zeitintervallen und Hitcounts) genau das was du willst, oder verstehe ich dich falsch?
ipt_recent ist bei meinem Debian Sarge Standart Kernel Packet als Modul dabei (aber leider mit Bug :() und wird automatisch geladen wenn man die entsprechende iptables Regeln benutzt.
a-n
Posts: 145
Joined: 2004-05-10 10:15
 

Re: iptables HTTP Flood pro IP

Post by a-n »

Code: Select all

connlimit - iptables connlimit match
Author: Gerd Knorr <kraxel@bytesex.org>  
Status: ItWorksForMe[tm] 


This adds an iptables match which allows you to restrict the
number of parallel TCP connections to a server per client IP address
(or address block).

Examples:

# allow 2 telnet connections per client host
iptables -p tcp --syn --dport 23 -m connlimit --connlimit-above 2 -j REJECT

# you can also match the other way around:
iptables -p tcp --syn --dport 23 -m connlimit ! --connlimit-above 2 -j ACCEPT

# limit the nr of parallel http requests to 16 per class C sized
# network (24 bit netmask)
iptables -p tcp --syn --dport 80 -m connlimit --connlimit-above 16 
	--connlimit-mask 24 -j REJECT

Das ist genau das was ich suche, habe einen neuen Kernel erstellt inkl. Patch-o-matic Patch. Werde morgen den Server rebooten und berichten.