Skip to content

netstat

85 commands

Shows network connections, listening ports, routing tables and interface statistics. Largely replaced by ss on Linux but still common everywhere.

  • connections
  • listening ports
  • legacy

Install netstat

sudo apt install net-tools

Basic Network Status3

netstat

Displays all active open network sockets and established connections.

Provides a baseline view of current system-wide network activity.

netstat -a

Shows all sockets, including both listening and established states (-a).

Comprehensive list of all ports regardless of their current status.

netstat -l

Lists only sockets that are currently in a listening state (-l).

Identifies ports waiting for incoming connection requests.

Numerical and Resolved Output2

netstat -n

Displays addresses and port numbers in numerical format (-n).

Accelerates output by skipping time-consuming DNS and service name lookups.

netstat -an

Shows all sockets and listening ports in numeric format (-an).

Combines comprehensive listing with high-performance numerical output.

TCP Connections5

netstat -t

Filters output to display only TCP protocol connections (-t).

Limits the view to Transmission Control Protocol session data.

netstat -at

Shows all TCP connections, including listening and active sessions (-at).

Provides a complete picture of all TCP-based service states.

netstat -lt

Lists only the TCP sockets currently waiting for connections (-lt).

Focuses on available TCP-based server services on the host.

netstat -tn

Displays TCP data with numerical addresses and ports (-tn).

Ideal for high-speed monitoring of active TCP sessions without DNS overhead.

netstat -ant

Combined view of all TCP sockets (listening and active) in numeric format (-ant).

Provides a rapid and detailed overview of the entire TCP stack state.

Link

UDP Connections5

netstat -u

Filters output to display only UDP protocol connections (-u).

Displays active and recently used User Datagram Protocol socket data.

Link
netstat -au

Shows all UDP connections, including listening sockets (-au).

Enables discovery of both established flows and available UDP services.

Link
netstat -lu

Lists only UDP sockets that are actively listening for packets (-lu).

Identifies open UDP ports that could be used for incoming payloads.

Link
netstat -un

Displays UDP connections with numerical addresses and ports (-un).

Provides a fast look at UDP traffic without resolving names.

Link
netstat -anu

Shows all UDP socket states in numerical format (-anu).

Comprehensive and efficient view of all local UDP service availability.

Link

UNIX Domain Sockets3

netstat -x

Displays information about active UNIX domain sockets (-x).

Makes local inter-process communication (IPC) channels visible for analysis.

Link
netstat -lx

Lists only listening UNIX domain sockets (-lx).

Identifies local system services waiting for internal application connections.

Link
netstat -ax

Shows all UNIX domain sockets, both listening and connected (-ax).

Full visualization of internal system-wide socket-based IPC.

Link

Raw Sockets1

netstat -w

Displays raw socket data if supported by the kernel (-w).

Enables visibility of low-level protocol interactions below the transport layer.

Link

Process and PID Association7

netstat -p

Shows the PID and program name for each network socket (-p).

Critically links network activity to specific running software processes.

Link
netstat -tp

Displays TCP connections with associated process IDs and names (-tp).

Maps transport layer activity directly to the initiating application.

Link
netstat -up

Displays UDP connections with associated process IDs and names (-up).

Identifies which system processes are handling datagram traffic.

Link
netstat -xlp

Lists listening UNIX sockets with their associated process info (-xlp).

Allows tracing of internal L5 services back to their binary sources.

Link
netstat -tulpn

Standard admin view of all listening TCP/UDP ports with PIDs (-tulpn).

Essential tool for auditing server security and verifying listening services.

Link
netstat -anp

Displays all connections and listening ports with PIDs numerically (-anp).

Provides maximum visibility into the entire active network footprint of the OS.

Link
netstat -ep

Shows process info with extended user ID and inode data (-ep).

Provides deep system integration details for socket-to-file matching.

Link

Extended and Verbose Output6

netstat -e

Displays extended socket info including owner UID and inode (-e).

Useful for determining the security context and identity of connection owners.

Link
netstat -ee

Displays very verbose kernel-level socket information (-ee).

Provides deepest possible visibility into internal networking structures.

Link
netstat -ne

Numerical addresses combined with extended owner details (-ne).

High-performance view that includes security identifier (UID) for each socket.

Link
netstat -v

Enables verbose mode, printing info on protocol family status (-v).

Helps diagnose why certain protocols may not be displaying active sockets.

Link
netstat -W

Enables wide mode to prevent address truncation (-W).

Ensures that long IPv6 or hostname strings are fully readable in the output.

Link
netstat -tunlpW

Shows listening TCP/UDP ports with PIDs and full IP strings (-tunlpW).

Full-detail admin view for comprehensive local service identification.

Link

Continuous and Periodic Output4

netstat -c

Updates the netstat output continuously every second (-c).

Enables real-time monitoring of connection state changes and bursts.

Link
netstat -tc

Continuously monitors TCP connection states every second (-tc).

Provides a live dashboard of Transmission Control Protocol activity.

Link
netstat -uc

Continuously monitors UDP datagram flow every second (-uc).

Identifies real-time spikes or patterns in User Datagram Protocol usage.

Link
netstat -anc

Continuously displays all connections in numeric format (-anc).

Monitors system-wide socket activity without DNS resolution delay.

Link

Timers and Advanced Info4

netstat -o

Displays network state timer information (-o).

Provides visibility into socket timeout, keepalive, and retransmission states.

Link
netstat -to

Shows TCP connections with their active timer states (-to).

Essential for diagnosing stuck sessions or performance-degrading retransmissions.

Link
netstat -anto

Displays all numerical TCP connections including active timers (-anto).

High-precision diagnostic view for transport-layer protocol behavior.

Link
netstat -apo

Shows all sockets with PIDs and timer data (-apo).

Enables deep debugging of process-specific network hang issues.

Link

Protocol Statistics4

netstat -s

Displays summary statistics for each network protocol (-s).

Aggregates error counts, packet totals, and flow metrics across the stack.

Link
netstat -su

Shows detailed statistics specifically for the UDP protocol (-su).

Useful for identifying datagram loss or buffer overflow issues in the stack.

Link
netstat -st

Shows detailed statistics specifically for the TCP protocol (-st).

Enables auditing of connection establishment, segments, and error rates.

Link
netstat -ss

Displays maximal protocol statistics including rare counters (-ss).

Deep-dive audit into low-level protocol event and failure statistics.

Link

Routing Table Display5

netstat -r

Displays the kernel IP routing table (-r).

Visualizes the system's pathing logic for different destination networks.

Link
netstat -rn

Displays the routing table with numerical IP addresses (-rn).

Prevents slow DNS lookups when auditing network routing configurations.

Link
netstat -rF

Displays the Forwarding Information Base routing table (-rF).

Shows the active forwarding rules used by the kernel for packet transit.

Link
netstat -rC

Displays the routing cache for recently used paths (-rC).

Provides visibility into recent destination routing decisions and metrics.

Link
netstat -rne

Numerical routing table with extended kernel info (-rne).

Detailed view of paths including MTU, window, and hop characteristics.

Link

Network Interface Statistics3

netstat -i

Displays a table of all network interfaces and statistics (-i).

Summary of RX/TX packet counts, errors, and drops for each adapter.

Link
netstat -ie

Displays interface statistics in a long format (-ie).

Provides detailed hardware configuration and status mirroring ifconfig output.

Link
netstat -ia

Shows statistics for all interfaces, including inactive ones (-ia).

Full inventory of physical and virtual networking hardware capabilities.

Link

Multicast and Broadcast Information2

netstat -g

Displays multicast group membership for local interfaces (-g).

Identifies which multicast groups the host is currently participating in.

Link
netstat -gn

Displays multicast groups with numerical interface IPs (-gn).

Clear accounting of multicast participation without resolution delays.

Link

IPv4 and IPv6 Views5

netstat -4

Filters output to show only IPv4 network connections (-4).

Excludes modern IPv6 data to focus on legacy stack auditing.

Link
netstat -6

Filters output to show only IPv6 network connections (-6).

Exposes active communications specifically on the modern IPv6 stack.

Link
netstat -l6

Displays only listening sockets on the IPv6 family (-l6).

Identifies services exclusively exposed via IPv6 transport protocols.

Link
netstat -u4

Displays only UDP connections using IPv4 (-u4).

Targets the User Datagram Protocol specifically on the IPv4 layer.

Link
netstat -t4n

Shows numerical TCP connections for IPv4 only (-t4n).

Highly specific, high-performance view of legacy transport session data.

Link

Port and Address Filtering3

netstat --numeric-ports

Resolves hostnames while keeping port numbers numerical (--numeric-ports).

Provides human-readable targets while maintaining exact technical port identification.

Link
netstat --numeric-hosts

Numerical IP addresses with service name resolution (--numeric-hosts).

Easily identifies the type of service (e.g. 'http') while keeping IPs exact.

Link
netstat --numeric-users

Shows numerical user IDs (UID) instead of names (--numeric-users).

Crucial for shell-based parsing where UID stability is preferred over names.

Link

Advanced and Combined Real World Analysis5

netstat -A inet

Filters connections to the 'inet' (IPv4) address family (-A inet).

Explicitly selects the IPv4 transport layer for detailed socket analysis.

Link
netstat -A inet6

Filters connections to the 'inet6' (IPv6) address family (-A inet6).

Focuses documentation and analysis on the modern IPv6 transport layer.

Link
netstat -A unix

Explicitly selects only UNIX domain socket family (-A unix).

Perfect for auditing internal local application inter-communication.

Link
netstat -aneo

Numeric view with extended details and connection timers (-aneo).

A deep TCP session analysis view including user identity and inode context.

Link
netstat -tupln

The ultimate standard command for listing all active listeners (-tupln).

Displays all TCP/UDP ports, numeric targets, and the owning process ID.

Link

Network Troubleshooting Scenarios4

netstat -tln

Quick check for open and listening TCP ports (-tln).

Fast standard method for verifying server service availability numerically.

Link
netstat -uln

Quick check for open and listening UDP ports (-uln).

Determines which datagram-based services are active on the host.

Link
netstat -rnC

Inspects the routing cache to debug routing decisions (-rnC).

Identifies why specific destination traffic might be taking an unexpected path.

Link
netstat -ie

Checks for RX/TX errors or dropped packets on interfaces (-ie).

Fundamental tool for diagnosing physical layer or driver-level throughput issues.

Link

Security and Incident Response Use Cases4

netstat -anp

Maps connection to PID for malware and intrusion hunting (-anp).

Identifies exact binaries initiating or receiving connections in suspicious patterns.

Link
netstat -antp

Focuses on TCP connections with PIDs to find backdoors (-antp).

Targets unauthorized remote shells or C2 traffic originating from the OS.

Link
netstat -anup

Focuses on UDP to find hidden datagram-based trojans (-anup).

Exposes non-stream communication channels used for data exfiltration.

Link
netstat -lxp

Audits local IPC sockets for suspicious local activities (-lxp).

Uncovers internal process masquerading or illegal local pipe usage.

Link

Blue Team Defensive Monitoring3

netstat -c -ant

Real-time monitor of TCP connections for new inbound probes (-c -ant).

Diagnostic tool for watching active port knocking or connection floods.

Link
netstat -s | grep -i retrans

Analyzes protocol retransmissions for DoS monitoring (-s).

High numbers of retransmits often indicate a significant network layer bottleneck.

Link
netstat -g

Verifies host membership in multicast discovery groups (-g).

Checks for participation in protocols like SSDP or mDNS for network leakage.

Link

Red Team Post Exploitation Validation3

netstat -ant | grep ESTABLISHED

Identifies currently active TCP sessions in ESTABLISHED state.

Quickly highlights active infiltration or admin sessions for hijack targeting.

Link
netstat -rn

Numerical routing map for internal subnet discovery (-rn).

Builds a logical picture of the network topology for internal pivoting planning.

Link
netstat -punta

Full-stack enumeration of all protocols and their binaries (-punta).

Maximum intensity reconnaissance of the targets' communication footprint.

Link

Legacy System Diagnostics4

netstat -M

Displays legacy IP masqueraded connections (-M).

Required for auditing NAT translation states on ancient Linux kernels.

Link
netstat --symbolic

Alternative syntax for enabling symbolic hostname resolution.

Forces the tool to translate IP addresses into readable domain names.

Link
netstat --route

Long-form argument for displaying the kernel routing table.

Human-readable equivalent to the -r flag for easier scripting maintenance.

Link
netstat --interfaces

Long-form argument for displaying the network interface table.

Explicitly calls for adapter-level TX/RX and error packet statistics.

Link