Table of Contents
netstat
is a network utility tool used to display network statistics and connection information. This tool provides information about various network connections, ports, protocols, and network interfaces. The netstat
command is commonly found on Linux, Unix, and Windows operating systems and can be used with various options.
The basic syntax for using netstat
is as follows:
netstat [options]
Here are some commonly used options with netstat
:
- -a (all): Display all connections and listening ports.
- -t (tcp): List TCP connections.
- -u (udp): List UDP connections.
- -n (numeric): Show numerical addresses and ports.
- -p (process): Show the process using the connection (works only on some systems).
- -r (route): Display the routing table.
For example, to view all TCP connections and ports:
netstat -t
or to view all connections and ports in numerical format:
netstat -an
The netstat
command is often used to diagnose network issues, identify used ports, or observe network traffic.
netstat
, a tool for displaying network connections, routing tables, interface statistics, masquerade connections, and multicast memberships:Basic Usage:
- Display All Connections:
netstat -a
- List All Listening Ports:
netstat -l
- Show Detailed Information (including PID):
netstat -p
Displaying Specific Protocol Connections:
- Show TCP Connections:
netstat -t
- Show UDP Connections:
netstat -u
- Display Only IPv4 Connections:
netstat -4
- Display Only IPv6 Connections:
netstat -6
Routing Table:
- Show Routing Table:
netstat -r
Interface Statistics:
- Show Interface Statistics:
netstat -i
Advanced:
- Display Network Services and Ports (Linux):
netstat -tulpn
- Display Network Services and Ports (Windows):
netstat -ano
- Show Kernel Routing Information (Linux):
netstat -r -n
- Display Network Statistics Since Boot:
netstat -s
Filtering and Formatting:
- Show Numerical Addresses:
netstat -n
- Display Continuous Output (Linux):
watch -n 1 netstat -an
- Display Continuous Output (Windows):
netstat -an 1
These commands cover some common use cases for netstat
. For more detailed information, you can refer to the netstat
manual (man netstat
on Linux).