|
嚜
Linux撘瑕之iptables嚗銝槐pt_recentmodule嚗賡餅DDoS餅
6 o" C. u& x/ t0 y" Y8 B; ~5 T+ U$ \* D靘憒嚗雿臭誑啣銝chain嚗 iptables -N WEB_SRV_DOS ":WEB_SRV_DOS - [0:0]"+ v- ^ F; y; ] ]+ E8 `
嗅嚗其誑銝隞歹60蝘吩it port 80/443頞10甈∠IP餅銝西銝靘嚗
- t! Y: x- o9 L: j! 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
銴鋆賭誨蝣 6 n" U0 l* q. N: d" `3 M: r3 e' O% A
憒雿dmesg唬憿航炊嚗
* Y- `( R; A- m5 L5 G Yhitcount (200) is larger than packets to be remembered (20) # ~8 x# r1 ^( f, @
銵函內雿閮剖閬閮蝞甈⊥詨之履pt_recent閮剖銝嚗舫隤踵惺pt_recent moduleip_pkt_list_tot訾閫瘙箝0 C- V9 ^+ w7 s0 {
$ `" \# B* Q; f: Z/ ]2 |8 G+ z p: k+ [
皜祈岫銝銝:, k u: R! b( M8 G) t2 t
撠皜祈岫site澆箏之 http request [size=13.376px](臭誑撖怎撘靘頝嚗冽雓撌乩犖箸 灸rowser憭TAB嚗銝瑞reload蝬脤)/ R9 e) _6 a% B+ Q2 c: I; ^
臭誑潛曉/var/log/message銝剖箇曆閮荔
' P1 R1 N. f3 o/ x7 _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- X0 z: ?$ Y0 z9 R6 T" w5 {2 Y6 p, k
甇斗隞半rowser皜祈岫蝬脤嚗箇遨onnection refused嚗⊥銝(箸閮剖rule爹EJECT)# V! c, Y- T3 H A
OK嚗iptablesipt_recent module潭桐其9 K) P! k5 C6 `1 z" [( P L# v
/ O% D( J- w+ t% }2 d蝯隢嚗
' I6 b# s0 D7 y' l2 m& |! c8 Z(1) iptables函雯頝臬惜喲餅餅撠嚗撠serverloading敶梢輯撠
0 a- y3 u: ~+ ^' K(2) iptables閮剖銝頛敶改舐其脰風80,443隞亙port
% H+ \: G$ H7 Z. E& f(3) iptables航身摰潛函銝餅嚗箏究erver寥脰靽霅瘀臭誑摰其霈餅撠脣叫erver7 k3 U3 Z# T6 H# ?
憒雿舐決S Windows + IIS嚗亙瑕嚗雿臭誑AQTRONIX WebKnight憟鞎餌web application firewall嚗鋆⊿W單脰風DDoS餅賬" X5 @+ o, J" L8 t
& [ s c! E+ K/ [2 b
+ L3 \( b% C5 n9 x. k: http://blog.eztable.com/2011/05/17/how-to-prevent-ddos/5 [8 N" i w( a) {
" a7 `" K+ m+ U* R; l7 A( r================================================% x) b( m+ r* c R9 A, \
菜葫舐IP 隞:7 I" l r* I& A2 j
sed 's/ .*//' access.log | sort | uniq -c | sort -n: g. Z: O. ~! j
perl -ne 'print "$1*\n" if m#^((\d+\.){3})#' access.log | sort | uniq -c | sort -n
6 W$ J( q" x7 R# s |
|
|