Netstat Tips and Tricks

The netstat command prints information about the UNIX and Linux networking subsystem such as the network connections, routing tables, masquerade connections, multicast memberships plus many more.

In this article, let’s review some of the netstat tips and tricks.

List Ports

List all open IPv4 and IPv6 ports.

List all TCP ports.

List all IPv4 TCP ports.

List all IPv6 TCP ports.

List all UDP ports.

List all IPv4 UDP ports.

List all IPv6 UDP ports.

List Ports in Specific State

List only listening ports. Append the commands with “-4” or “-6” option as shown in the previous examples to filter for IPv4 or IPv6 ports.

List only listening TCP ports.

List only TCP ports in ESTABLISHED state.

List only listening UDP ports.

List only listening UNIX domain sockets.

Network Statistics

Print TCP network statistics.

Print UDP network statistics.

Print RAW (IP and ICMP) network statistics.

Show PID and Process Name of Socket

If you want to determine which PID or process is listening on a port, use the “-p” option. This option is most useful when run as root.

Print all the PIDs and process name of the IPv4 TCP ports.

Non Supported Address Families

Print all the non supported network address families on the system.

List Network Interfaces

Print a table of all network interfaces.

Print network interfaces with additional information.

List Kernel Routing Table

Print a kernel routing table in numeric format.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }