|
嚜
Linux撘瑕之iptables嚗銝槐pt_recentmodule嚗賡餅DDoS餅
. u2 V7 l, {7 j x" M$ Q2 P4 y靘憒嚗雿臭誑啣銝chain嚗 iptables -N WEB_SRV_DOS ":WEB_SRV_DOS - [0:0]"
& [: Y% m6 I7 |$ [9 x嗅嚗其誑銝隞歹60蝘吩it port 80/443頞10甈∠IP餅銝西銝靘嚗
7 Q4 Y8 L. v5 o- 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
銴鋆賭誨蝣
% s7 U% J" r6 Z, |0 {. d憒雿dmesg唬憿航炊嚗
9 p3 i# j/ H( }0 t' z4 chitcount (200) is larger than packets to be remembered (20)
9 D- {" `! t# x# E8 T銵函內雿閮剖閬閮蝞甈⊥詨之履pt_recent閮剖銝嚗舫隤踵惺pt_recent moduleip_pkt_list_tot訾閫瘙箝
, ~. E: D8 P0 N& M! U. }
0 T$ [$ x0 Q( M皜祈岫銝銝:1 ^8 G) `8 J6 B6 [1 r- T* B
撠皜祈岫site澆箏之 http request [size=13.376px](臭誑撖怎撘靘頝嚗冽雓撌乩犖箸 灸rowser憭TAB嚗銝瑞reload蝬脤)% P+ J; k- J# s# L6 `
臭誑潛曉/var/log/message銝剖箇曆閮荔6 B) I$ G6 [; R7 f/ t+ Z* K
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
$ p3 {, N3 z( m& R甇斗隞半rowser皜祈岫蝬脤嚗箇遨onnection refused嚗⊥銝(箸閮剖rule爹EJECT)
6 c, m4 c9 L5 w. wOK嚗iptablesipt_recent module潭桐其
/ v* {2 R9 C" i \! d4 k3 `' h8 v- R; g0 m, m# l* W4 f1 x% B0 c4 S* \
蝯隢嚗
5 F+ G, ~2 F! O# B(1) iptables函雯頝臬惜喲餅餅撠嚗撠serverloading敶梢輯撠
9 i7 `5 l- A' G; |(2) iptables閮剖銝頛敶改舐其脰風80,443隞亙port( q- ~% c& y9 G4 Z. k' d& U
(3) iptables航身摰潛函銝餅嚗箏究erver寥脰靽霅瘀臭誑摰其霈餅撠脣叫erver
. h7 ~* a- t7 h5 _! i I憒雿舐決S Windows + IIS嚗亙瑕嚗雿臭誑AQTRONIX WebKnight憟鞎餌web application firewall嚗鋆⊿W單脰風DDoS餅賬
$ b8 r q, U! B+ ?7 }% ?* h( L7 P! w j' e* H& r( E3 Z
& b# z" R( e! Q; Z% ^4 k; f% X: http://blog.eztable.com/2011/05/17/how-to-prevent-ddos/2 s. k- l& T. t; s
9 B3 L* o' J& C' [: v4 T
================================================0 p% w8 M/ V. |: u1 b: x
菜葫舐IP 隞:
( w4 \1 { v/ ]sed 's/ .*//' access.log | sort | uniq -c | sort -n0 F6 f$ R9 p3 t6 ~$ r! P7 K# ?
perl -ne 'print "$1*\n" if m#^((\d+\.){3})#' access.log | sort | uniq -c | sort -n
' {% a+ N0 A" i m# P8 u |
|
|