Diagnose Network Issues - netstat

Netstat (NETwork STATistics) is a command-line tool that provides information about our network configuration and activity. Notice that the netstat command behaves differently on Windows and OSX.


Display routing table (Win/OSX)

1
netstat -rn

-r: Kernel routing tables.
-n: Shows numerical addresses instead of trying to determine hosts.


Display all opened sockets (Win/OSX)

1
netstat -a

-a: All


Display opened TCP/UDP socket (OSX)

1
netstat -ut

-u: UDP
-t: TCP


Display all listening state sockets (OSX)

Show all listening ports

1
netstat -l

-l: Listening state sockets

Show all TCP listening ports

1
netstat -lt

-l: Listening state sockets
-t: TCP

Show all UDP listening ports

1
netstat -lu

-l: Listening state sockets
-u: UDP


Display summary statistics for each protocol (Win/OSX)

1
netstat -s

-s: Summary statistics for each protocol.


Reference

OpenManiak
10 basic examples of linux netstat command