[root@localhost ~]# netstat -ntlp //查看当前所有tcp端口· [root@localhost ~]# netstat -ntulp |grep 80 //查看所有80端口使用情况· [root@localhost ~]# netstat -an | grep 3306 //查看所有3306端口使用情况· [root@localhost ~]# netstat -nlp |grep LISTEN //查看当前所有监听端口·
LISTEN:(Listening for a connection.)侦听来自远方的TCP端口的连接请求
SYN-SENT:(Active; sent SYN. Waiting for a matching connection request after having sent a connection request.)再发送连接请求后等待匹配的连接请求
SYN-RECEIVED:(Sent and received SYN. Waiting for a confirming connection request acknowledgment after having both received and sent connection requests.)再收到和发送一个连接请求后等待对方对连接请求的确认
ESTABLISHED:(Connection established.)代表一个打开的连接
FIN-WAIT-1:(Closed; sent FIN.)等待远程TCP连接中断请求,或先前的连接中断请求的确认
FIN-WAIT-2:(Closed; FIN is acknowledged; awaiting FIN.)从远程TCP等待连接中断请求
CLOSE-WAIT:(Received FIN; waiting to receive CLOSE.)等待从本地用户发来的连接中断请求
CLOSING:(Closed; exchanged FIN; waiting for FIN.)等待远程TCP对连接中断的确认
LAST-ACK:(Received FIN and CLOSE; waiting for FIN ACK.)等待原来的发向远程TCP的连接中断请求的确认
TIME-WAIT:(In 2 MSL (twice the maximum segment length) quiet wait after close. )等待足够的时间以确保远程TCP接收到连接中断请求的确认
CLOSED:(Connection is closed.)没有任何连接状态
1.查找请求数前20个IP(常用于查找攻来源): netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20 netstat -ant |awk '/:80/{split($5,ip,”:”);++A[ip[1]]}END{for(i in A) print A[i],i}' |sort -rn|head -n20 2.用tcpdump嗅探80端口的访问看看谁最高 tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F”.” '{print $1″.”$2″.”$3″.”$4}' | sort | uniq -c | sort -nr |head -20 3.查找较多time_wait连接 netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20 4.找查较多的SYN连接 netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr | more 5.根据端口列进程 netstat -ntlp | grep 80 | awk '{print $7}' | cut -d/ -f1
作者:OK兄 浏览次数:34