netstat及tcp狀態

netsat

netstat -ant

獲得html

root@f6c0aba5201d:/# netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp6       0      0 :::8080                 :::*                    LISTEN
tcp6      52      0 172.17.0.2:8080         192.168.99.1:56750      ESTABLISHED
tcp6       0      0 172.17.0.2:8080         192.168.99.1:56503      TIME_WAIT
tcp6      52      0 172.17.0.2:8080         192.168.99.1:56788      ESTABLISHED
tcp6       0      0 172.17.0.2:8080         192.168.99.1:56686      TIME_WAIT
tcp6       0      0 172.17.0.2:8080         192.168.99.1:56658      TIME_WAIT
tcp6       0      0 172.17.0.2:8080         192.168.99.1:56723      TIME_WAIT
tcp6      52      0 172.17.0.2:8080         192.168.99.1:56695      ESTABLISHED
tcp6       0      0 172.17.0.2:8080         192.168.99.1:56688      TIME_WAIT
tcp6       0      0 172.17.0.2:8080         192.168.99.1:56701      TIME_WAIT

總體統計

netstat -an | awk '/^tcp/ {++S[$NF]} END {for (a in S) print a, S[a]}'

獲得shell

root@f6c0aba5201d:/# netstat -an | awk '/^tcp/ {++S[$NF]} END {for (a in S) print a, S[a]}'
LISTEN 1
TIME_WAIT 22
ESTABLISHED 96

TCP的狀態機

clipboard.png

創建鏈接時對應的狀態

clipboard.png

doc

相關文章
相關標籤/搜索