|
嚜
Linux撘瑕之iptables嚗銝槐pt_recentmodule嚗賡餅DDoS餅7 n. f4 H- R7 h3 M
靘憒嚗雿臭誑啣銝chain嚗 iptables -N WEB_SRV_DOS ":WEB_SRV_DOS - [0:0]"
, W1 H5 Z! G1 k& e9 @* O嗅嚗其誑銝隞歹60蝘吩it port 80/443頞10甈∠IP餅銝西銝靘嚗9 H; G& s3 ?( o: H! s
- 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
銴鋆賭誨蝣 - r: V$ M* D3 U& b3 p. m- O
憒雿dmesg唬憿航炊嚗 : D8 d, c0 v5 ?4 y- |
hitcount (200) is larger than packets to be remembered (20)
k Q2 j8 e. a" g4 Y3 A銵函內雿閮剖閬閮蝞甈⊥詨之履pt_recent閮剖銝嚗舫隤踵惺pt_recent moduleip_pkt_list_tot訾閫瘙箝, f6 f7 z+ A x8 s3 _( H6 ]4 [
/ u( I0 I0 f8 }& [+ F1 S* Y皜祈岫銝銝:
" Y$ v( u+ V" r7 i. \撠皜祈岫site澆箏之 http request [size=13.376px](臭誑撖怎撘靘頝嚗冽雓撌乩犖箸 灸rowser憭TAB嚗銝瑞reload蝬脤)3 Q A. t3 ]6 }0 q
臭誑潛曉/var/log/message銝剖箇曆閮荔& f, c% k5 j/ s
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=03 b# _) b7 h* r/ V/ f' c
甇斗隞半rowser皜祈岫蝬脤嚗箇遨onnection refused嚗⊥銝(箸閮剖rule爹EJECT); L/ X1 r1 |$ z3 p
OK嚗iptablesipt_recent module潭桐其5 ~% [* m. k; d: y& w3 t! m7 U1 s
, U# o: @1 x5 q8 q9 L6 g蝯隢嚗
1 {) q& [" q+ ^7 z3 H; z( `(1) iptables函雯頝臬惜喲餅餅撠嚗撠serverloading敶梢輯撠
7 w2 Q7 y% Y, k3 N+ ?; z( p(2) iptables閮剖銝頛敶改舐其脰風80,443隞亙port4 R X. E" L. a
(3) iptables航身摰潛函銝餅嚗箏究erver寥脰靽霅瘀臭誑摰其霈餅撠脣叫erver9 ^0 K- |# F# ^ o( P$ m: ]
憒雿舐決S Windows + IIS嚗亙瑕嚗雿臭誑AQTRONIX WebKnight憟鞎餌web application firewall嚗鋆⊿W單脰風DDoS餅賬
4 r+ B, t/ x- R$ E# o3 l0 g9 L% i- v! I$ m1 O+ \
_4 l7 r, H; p" U9 k: http://blog.eztable.com/2011/05/17/how-to-prevent-ddos/0 P* g* ` N: h3 N
% y- W4 m% w8 Y b
================================================% }+ K# b2 w6 L: v
菜葫舐IP 隞:# z" R$ }! w2 w" k- h
sed 's/ .*//' access.log | sort | uniq -c | sort -n
# B9 V. b+ y5 h" M; m) g aperl -ne 'print "$1*\n" if m#^((\d+\.){3})#' access.log | sort | uniq -c | sort -n
" [+ _, E8 r1 [: t |
|
|