Skip to content

Instantly share code, notes, and snippets.

@1901
Created August 12, 2019 13:13
Show Gist options
  • Save 1901/22f2eec17497a752af79ed26bb4912ea to your computer and use it in GitHub Desktop.
Save 1901/22f2eec17497a752af79ed26bb4912ea to your computer and use it in GitHub Desktop.
[netstat] #linux #network
# 按状态统计
netstat -nat | awk '{print $6}' | sort | uniq -c |sort -rn
# 按本机到外部80端口的访问统计
netstat -nat | grep ESTABLISHED | awk '{print $5}' | grep :80 | sort | uniq -c | sort -rn
# 按外部到本机80端口的访问统计
netstat -nat | grep ESTABLISHED | awk '{print $4}' | grep :80 | sort | uniq -c | sort -rn
# ESTABLISHED 正在通信
# TIME_WAIT 主动关闭
# CLOSE_WAIT 被动关闭
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment