awk, cut, sort, uniq 隞, 臭誑啣箸 ip 蝺賊, 銝衣券蝺賊摨勗撠, 隞乩撠 TCP ESTABLISHED 蝺瑼X:- netstat -an|grep ESTABLISHED|awk '/^tcp/ {print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|more
銴鋆賭誨蝣 撠 port 80 蝺, 撠瘥 ip 蝺賊啣箔蒂脰摨:- netstat -ntu | grep :80 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr|more
銴鋆賭誨蝣 箸憭交貊 10 IP 園交賂嗡葉 :80 舫亙嚗舀寞唾瑼X亦- netstat -atnp -A inet | grep ":80" | awk -F " " '{print $5}' | awk -F ":" '{print $1}' | sort | uniq -c | sort -nr | head -10
銴鋆賭誨蝣 1 ^5 W* k- M/ R' k: g
隞乩寞曉唬皞 ip 敺, 靘憒 ip x.x.x.x, 臭誑 iptables 餅餅7 Q6 X/ H! J8 ] C0 h
撠 IP- iptables -A INPUT -p all -s x.x.x.x/32 -j DROP
銴鋆賭誨蝣 閫文 IP- iptables -D INPUT -p all -s x.x.x.x/32 -j DROP
銴鋆賭誨蝣 隞乩:
% s/ h4 b, t5 {+ a/ C& Qhttps://www.phpini.com/linux/linux-netstat-detect-ddos
! {7 D. L4 `: Ghttps://www.phpini.com/linux/count-ip-connections# h& E- o: r, r& G5 {6 |
https://www.phpini.com/linux/netstat-check-connections. E/ o% M j% l/ P5 F
=================================================, ^5 U7 k+ m0 _7 D
血嚗4 A3 P, K1 W, r8 W+ e1 E# L
亥岷芯port鋡怠芯函撘雿剁
& H3 Q- y* B4 y5 ^1 k0 n1.)- netstat -tulpn | grep LISTEN
銴鋆賭誨蝣 2.)- lsof -i -P -n | grep LISTEN
銴鋆賭誨蝣 3.)- sudo nmap -sT -O localhost
銴鋆賭誨蝣 =================================================) S ^8 L/ D; h& {& H0 s4 C: m1 w" m
亥岷port雿函backlogbacklog閰脣憭改 嚗 https://cloud.tencent.com/developer/article/1644836: z: a7 R l1 c- I3 p! `4 J# s
|
|