|
嚜
Linux撘瑕之iptables嚗銝槐pt_recentmodule嚗賡餅DDoS餅
$ M; N; Q6 E Y# M- E; H' Y; b靘憒嚗雿臭誑啣銝chain嚗 iptables -N WEB_SRV_DOS ":WEB_SRV_DOS - [0:0]"
* g; K G% P+ w$ o; N嗅嚗其誑銝隞歹60蝘吩it port 80/443頞10甈∠IP餅銝西銝靘嚗# _+ s6 R. t( }/ X9 J0 j. h
- 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
銴鋆賭誨蝣 # k# Y, i. @9 l" ?) T( V1 F
憒雿dmesg唬憿航炊嚗 ' v( @! q7 }8 T2 ^8 p
hitcount (200) is larger than packets to be remembered (20) 9 B8 n8 w9 l h& Z X
銵函內雿閮剖閬閮蝞甈⊥詨之履pt_recent閮剖銝嚗舫隤踵惺pt_recent moduleip_pkt_list_tot訾閫瘙箝+ b( f4 _, s. F9 @7 y
2 \; n! Y. Z0 a- p8 Y1 q皜祈岫銝銝:% Y6 t) ]( P u6 U
撠皜祈岫site澆箏之 http request [size=13.376px](臭誑撖怎撘靘頝嚗冽雓撌乩犖箸 灸rowser憭TAB嚗銝瑞reload蝬脤)
" q% f0 m/ S* {, g臭誑潛曉/var/log/message銝剖箇曆閮荔* ]9 A& R6 u+ X8 o* z, a
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
/ m, O- y d7 G$ D( S$ g甇斗隞半rowser皜祈岫蝬脤嚗箇遨onnection refused嚗⊥銝(箸閮剖rule爹EJECT)2 |$ O2 E+ T' n' K& H
OK嚗iptablesipt_recent module潭桐其' b- b0 Y: B* Q" R
7 N) e+ D( i$ Q2 `
蝯隢嚗" ^/ s8 L& Y& D' L
(1) iptables函雯頝臬惜喲餅餅撠嚗撠serverloading敶梢輯撠! P' |+ E8 C! D7 k( I
(2) iptables閮剖銝頛敶改舐其脰風80,443隞亙port. ~9 M3 e" g! ^8 b1 R
(3) iptables航身摰潛函銝餅嚗箏究erver寥脰靽霅瘀臭誑摰其霈餅撠脣叫erver
* V7 T" ]- k# F9 q憒雿舐決S Windows + IIS嚗亙瑕嚗雿臭誑AQTRONIX WebKnight憟鞎餌web application firewall嚗鋆⊿W單脰風DDoS餅賬) C2 S. |7 |( L3 `& K' [/ R4 d8 j
2 P R' Q4 W# F- J- Q
8 y1 ~, A% R8 i# o" Y# @; a: http://blog.eztable.com/2011/05/17/how-to-prevent-ddos/1 _. V1 [1 A; z# w/ A
: c5 d& d J/ h1 Y ]) B. S================================================
0 X( h& D& W% u0 }( j; N菜葫舐IP 隞:
6 Z1 _3 x) Q1 s: N: j/ _, j1 C/ ]sed 's/ .*//' access.log | sort | uniq -c | sort -n
# z6 S! p7 p% m6 h1 F& rperl -ne 'print "$1*\n" if m#^((\d+\.){3})#' access.log | sort | uniq -c | sort -n
5 j4 k B$ y9 Y* a2 s |
|
|