|
嚜
Linux撘瑕之iptables嚗銝槐pt_recentmodule嚗賡餅DDoS餅
% X. R, F/ b$ m2 a% |# D- ?靘憒嚗雿臭誑啣銝chain嚗 iptables -N WEB_SRV_DOS ":WEB_SRV_DOS - [0:0]"
4 C& T( a+ X. A; x7 l% ?3 l: c9 P嗅嚗其誑銝隞歹60蝘吩it port 80/443頞10甈∠IP餅銝西銝靘嚗
, F0 L1 J8 N( J* N- 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
銴鋆賭誨蝣 # b& q- ~. X6 _+ \
憒雿dmesg唬憿航炊嚗 ) i; v: ], _+ t- k: n
hitcount (200) is larger than packets to be remembered (20)
% {# X. t3 Z' p2 @+ t6 F銵函內雿閮剖閬閮蝞甈⊥詨之履pt_recent閮剖銝嚗舫隤踵惺pt_recent moduleip_pkt_list_tot訾閫瘙箝
; H9 y% H7 B' u; h3 _* [
6 l8 ~4 | R' `+ c3 |- b7 e. q皜祈岫銝銝:
! M+ Q3 d' F+ o3 u L撠皜祈岫site澆箏之 http request [size=13.376px](臭誑撖怎撘靘頝嚗冽雓撌乩犖箸 灸rowser憭TAB嚗銝瑞reload蝬脤)
& a2 r/ Y/ K% E! m9 T7 R臭誑潛曉/var/log/message銝剖箇曆閮荔
2 [2 l( R- w8 o3 b- s. Z P7 z9 L4 nMay 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- V9 U n, m2 W8 P! M
甇斗隞半rowser皜祈岫蝬脤嚗箇遨onnection refused嚗⊥銝(箸閮剖rule爹EJECT)
& i1 S) [! b2 s. D9 {3 [OK嚗iptablesipt_recent module潭桐其
# j& C" D$ _" l* U$ g% Q. U$ B
. R# ^' }- P1 {% M7 A: u+ Z$ r蝯隢嚗, A4 l% r, X' ?, \+ z
(1) iptables函雯頝臬惜喲餅餅撠嚗撠serverloading敶梢輯撠- t# m* n+ H" _+ j& v
(2) iptables閮剖銝頛敶改舐其脰風80,443隞亙port( Z# {, j+ E: s* O% s
(3) iptables航身摰潛函銝餅嚗箏究erver寥脰靽霅瘀臭誑摰其霈餅撠脣叫erver
8 r* N' U% \1 j( s! h& d, x' c1 Q5 c# W憒雿舐決S Windows + IIS嚗亙瑕嚗雿臭誑AQTRONIX WebKnight憟鞎餌web application firewall嚗鋆⊿W單脰風DDoS餅賬
0 M* S! }% V. K5 t( S" a7 \; n: {
; Q7 \. J% n# B: http://blog.eztable.com/2011/05/17/how-to-prevent-ddos/4 \7 P: v3 ]* V7 I0 R
8 u* _% H2 U8 w, w6 n: j
================================================
$ ]+ R1 U* b6 A6 q; Z5 u0 C7 D菜葫舐IP 隞:3 f7 j/ G2 D4 k8 i; A! ]4 H3 e
sed 's/ .*//' access.log | sort | uniq -c | sort -n
" e z ?$ a/ m0 ^perl -ne 'print "$1*\n" if m#^((\d+\.){3})#' access.log | sort | uniq -c | sort -n+ F( L* R( ?0 u2 Y
|
|
|