The netstat
command is a powerful tool used to display network connections, routing tables, interface statistics, and more. It helps users monitor network activity and diagnose network issues.
The basic syntax of the netstat
command is as follows:
netstat [options] [arguments]
-a
: Show all active connections and listening ports.-n
: Display addresses and port numbers in numerical form rather than resolving them to hostnames.-r
: Display the routing table.-i
: Show network interface statistics.-p
: Show the process ID and name associated with each connection.Here are some practical examples of using the netstat
command:
netstat -a
netstat -an
netstat -r
netstat -i
netstat -p
-n
option to speed up the output by avoiding DNS lookups, especially useful on busy networks.netstat -anp
to see all connections with process information.