|
|
嚜
Linux撘瑕之iptables嚗銝槐pt_recentmodule嚗賡餅DDoS餅0 Z$ B+ q9 C7 N: l& U, p
靘憒嚗雿臭誑啣銝chain嚗 iptables -N WEB_SRV_DOS ":WEB_SRV_DOS - [0:0]"
* t% O9 R F ]2 Z0 T嗅嚗其誑銝隞歹60蝘吩it port 80/443頞10甈∠IP餅銝西銝靘嚗& M Z& \) G- ]9 S( x
- iptables -A INPUT -p tcp -m multiport dports 80,443 -j WEB_SRV_DOS
- iptables -A WEB_SRV_DOS -p tcp --syn -m multiport --dports 80,443 -m recent --rcheck --second 60 --hitcount 10 -j LOG --log-prefix "[Possible DOS Attack]"
- iptables -A WEB_SRV_DOS -p tcp --syn -m multiport --dports 80,443 -m recent --rcheck --second 60 --hitcount 10 -j REJECT
- iptables -A WEB_SRV_DOS -p tcp --syn -m multiport --dports 80,443 -m recent --set
- iptables -A WEB_SRV_DOS -p tcp -m multiport --dports 80,443 -j ACCEPT
銴鋆賭誨蝣
- g: o9 r2 r+ W/ m: B) C憒雿dmesg唬憿航炊嚗
+ i( c0 e* r, ]! z7 Z% h5 |1 ihitcount (200) is larger than packets to be remembered (20) 9 o( E# I7 X' y/ ]
銵函內雿閮剖閬閮蝞甈⊥詨之履pt_recent閮剖銝嚗舫隤踵惺pt_recent moduleip_pkt_list_tot訾閫瘙箝( |. L6 p) y9 J3 h& \
: B: |* i$ J0 n9 t8 |4 A* W# f, L7 U1 W
皜祈岫銝銝:
4 `( p) t3 U. l8 y& f9 U撠皜祈岫site澆箏之 http request [size=13.376px](臭誑撖怎撘靘頝嚗冽雓撌乩犖箸 灸rowser憭TAB嚗銝瑞reload蝬脤), J/ B1 I0 B% i9 |8 w7 F" j' W
臭誑潛曉/var/log/message銝剖箇曆閮荔9 J1 }+ N: y0 R& Y
May 17 07:12:00 localhost kernel: [Possible DOS Attack]IN=eth0 OUT= MAC=XX:XX:XX:XX:43:77:00:1f:YY:YY:YY:YY SRC=192.168.0.105 DST=192.168.0.102 LEN=64 TOS=0x00 PREC=0x00 TTL=64 ID=45026 DF PROTO=TCP SPT=59437 DPT=80 WINDOW=65535 RES=0x00 SYN URGP=0* K6 L7 M" H; s2 x* g: d b
甇斗隞半rowser皜祈岫蝬脤嚗箇遨onnection refused嚗⊥銝(箸閮剖rule爹EJECT): H) X) E# F- V1 t. t6 J) z
OK嚗iptablesipt_recent module潭桐其1 d5 H- |' N& T: g0 c
: w& N1 m" q0 X
蝯隢嚗$ b6 o$ i2 O/ F2 V& G' W) r
(1) iptables函雯頝臬惜喲餅餅撠嚗撠serverloading敶梢輯撠
5 {2 ~1 \0 q( r4 Y% y$ T(2) iptables閮剖銝頛敶改舐其脰風80,443隞亙port
* [7 S: g/ A7 M4 `4 |- `) V* K! a(3) iptables航身摰潛函銝餅嚗箏究erver寥脰靽霅瘀臭誑摰其霈餅撠脣叫erver
e# w3 {) o) L) ^! J: B憒雿舐決S Windows + IIS嚗亙瑕嚗雿臭誑AQTRONIX WebKnight憟鞎餌web application firewall嚗鋆⊿W單脰風DDoS餅賬& _0 J# x- c3 G6 r" l# X3 _8 ]0 R
1 o" ^* [/ n$ V0 ~; n8 a/ Q8 L' f+ L; H& _0 F) M
: http://blog.eztable.com/2011/05/17/how-to-prevent-ddos/ D* O- C& K$ Z* J! S1 B
; P* R5 K/ `8 k. R0 B6 P
================================================8 a+ Y! j; u2 J
菜葫舐IP 隞:/ {+ _" R% W/ P5 e" r" W
sed 's/ .*//' access.log | sort | uniq -c | sort -n
( l: J. r3 T9 b; a" y `perl -ne 'print "$1*\n" if m#^((\d+\.){3})#' access.log | sort | uniq -c | sort -n
5 q% E3 h% q8 ]0 S |
|
|