Disce aut Discede
Learn or Leave
Add post
Tags : net netstat tips

List all currently established connections and (if run as root) process asociated:

$ netstat -punta


List all listening sockets and process listening:

$netstat -plunt


List number of connections by state:

$ netstat -ant | awk '{print $NF}' | grep -v '[a-z]' | sort | uniq -c 2 CLOSE_WAIT 23 ESTABLISHED 23 LISTEN 1 SYN_RECV


List how many connections has each IP:

$ netstat -ntu | awk ' $5 ~ /^[0-9]/ {print $5}' | cut -d: -f1 | sort | uniq -c | sort -n 1 138.160.172.193 1 138.77.215.108 1 168.105.34.129 1 159.68.194.3 1 159.68.194.36 1 219.115.59.168 1 215.11.43.242 1 37.59.71.155 1 52.4.177.28 1 54.73.102.164 1 66.102.1.198 1 74.121.103.108 1 74.121.86.109 1 85.203.152.195 2 94.133.126.109 2 83.201.153.198 3 127.0.0.1 4 191.225.179.217


To show all listening Unix sockets

$ netstat -lx