Netstat Cheatsheet

0
1738

To view the total number of connections to a port, run the following command in ssh

netstat -tuna | awk -F':+| +' 'NR>2{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

netstat with group by ip adress

netstat -ntu | awk ‘ $5 ~ /^[0-9]/ {print $5}’ | cut -d: -f1 | sort | uniq -c | sort -n
netstat -ntu | awk ‘ $5 ~ /^(::ffff:|[0-9|])/ { gsub(“::ffff:”,””,$5); print $5}’ | cut -d: -f1 | sort | uniq -c | sort -nr
netstat -nt | awk -F”:” ‘{print $2}’ | sort | uniq -c
netstat -antu | grep :80 | grep -v LISTEN | awk '{print $5}' | cut -d: -f1 | sort | uniq -c
netstat -antu | grep :3306 | grep -v LISTEN | awk '{print $5}' | cut -d: -f1 | sort | uniq -c

LEAVE A REPLY

Please enter your comment!
Please enter your name here