The “netstat” command is a network utility tool available in most operating systems, including Windows, Linux, and macOS. It provides information about network connections, routing tables, interface statistics, masquerade connections, and more. Here’s an overview of how to use “netstat” and some common options:
Basic Syntax:
bash
netstat [options]
Common Options:
– “-a (or –all)“: Show both listening and non-listening sockets.
bash
netstat -a
– “-t (or –tcp)“: Display only TCP connections.
bash
netstat -t
– “-u (or –udp)“: Display only UDP connections.
bash
netstat -u
– “-n (or –numeric)“: Show numerical addresses instead of resolving hosts.
bash
netstat -n
– “-p (or –programs)“: Display the process ID and name for each connection.
bash
netstat -p
– “-r (or –route)“: Display the kernel routing table.
bash
netstat -r
– “-s (or –statistics)“: Display networking statistics.
bash
netstat -s
– “-l (or –listening)“: Display only listening sockets.
bash
netstat -l
Examples:
1. Show All Connections:
bash
netstat -a
2. Display TCP Connections:
bash
netstat -t
3. Show UDP Connections:
bash
netstat -u
4. Display Routing Table:
bash
netstat -r
5. Show Listening Sockets:
bash
netstat -l
6. Display Process IDs and Names:
bash
netstat -p
7. Show Numerical Addresses:
bash
netstat -n
Important Notes:
– Running “netstat” without any options will display a list of all active connections.
– Some options may require administrative privileges to display certain information.
– On Windows, you might need to use “netstat -an” to display all active connections with numerical addresses.
“netstat” is a powerful tool for diagnosing network-related issues and understanding the status of network connections on your system. The specific options you use will depend on the information you’re seeking.