GO KALI FREE
Networking Commands

netstat Linux Command

Displays network connections, routing tables, interface statistics, and more.

What does netstat do?

Displays network connections, routing tables, interface statistics, and more.

Syntax

netstat [options]

Practical example

netstat -tulpn

Questions about netstat

How do I see all active connections?

Use `netstat -a` to display all active connections including listening sockets and TCP/UDP connections.

What does netstat -tulpn show?

`-t` shows TCP, `-u` shows UDP, `-l` shows listening ports, `-p` shows process names, `-n` shows numeric addresses (no DNS resolution).

How do I see which ports are listening?

Use `netstat -tlnp` to show all listening TCP ports with the process using each port. This is essential for checking open services.

How do I see the routing table with netstat?

Use `netstat -r` or `netstat -rn` (numeric, no DNS) to display the kernel routing table.

How do I see network interface statistics?

Use `netstat -i` to display packet counts, errors, and other statistics for each network interface.

Why is netstat deprecated?

netstat is part of the net-tools package. The `ss` command is the modern replacement that is faster and provides more socket information.

How do I install netstat?

On Debian/Ubuntu: `sudo apt install net-tools`. On RHEL/CentOS: `sudo yum install net-tools`.

How do I see connections by state?

Use `netstat -an | grep ESTABLISHED` to see only established connections. Replace ESTABLISHED with LISTEN, TIME_WAIT, etc.

Related Networking Commands

ip

Modern replacement for ifconfig. Shows and manipulates routing, devices, and tunnels.

ss

Modern replacement for netstat. Dumps socket statistics quickly.

ifconfig

Displays or configures network interface parameters (deprecated, use ip).

curl

Transfers data from or to a server using various protocols (HTTP, FTP, etc.).

ping

Sends ICMP echo request packets to test network connectivity to a host.

wget

Downloads files from the internet non-interactively via HTTP, HTTPS, or FTP.