How to use 20 Netstat commands for Linux Network Management

Estimated reading: 3 minutes 369 views
  • netstat is a useful tool for checking your network configuration and activity. It is in fact a collection of several tools lumped together
  • netstat tool is very important and much useful for Linux network administrators as well as system administrators to monitor and troubleshoot their network-related problems and determine network traffic performance.
  • netstat is one of the most basic network service debugging tools, telling you what ports are open and whether any programs are listening on ports.
    This article shows usages of netstat command with their examples which may be useful in daily operation.

1. Listing all the LISTENING Ports of TCP and UDP Connections

Listing all ports (both TCP and UDP) using option: netstat -a

2. Listing TCP Ports connections

Listing only TCP (Transmission Control Protocol) port connections using: netstat -at

3. Listing UDP Ports connections

Listing only UDP (User Datagram Protocol ) port connections using: netstat -au

4. Listing all LISTENING Connections

Listing all active listening ports connections with: netstat -l

5. Listing all TCP Listening Ports

Listing all active listening TCP ports by using option: netstat -lt

6. Listing all UDP Listening Ports

Listing all active listening UDP ports by using option: netstat -lu

7. Listing all UNIX Listening Ports

Listing all active UNIX listening ports using: netstat -lx

 8. Showing Statistics by Protocol

Displays statistics by protocol. By default, statistics are shown for the TCP, UDP, ICMP, and IP protocols. The -s parameter can be used to specify a set of protocols

netstat -s

9. Showing Statistics by TCP Protocol

Showing statistics of only TCP protocol by using option: netstat -st

10. Showing Statistics by UDP Protocol

netstat -su

11. Displaying Service name with PID

Displaying service name with their PID number, using option netstat -tp will display “PID/Program Name

netstat -tp

 

12. Displaying Promiscuous Mode

Displaying Promiscuous mode with -ac switch, netstat print the selected information or refresh screen every five seconds. The default screen refreshes every second

netstat -ac 5 | grep tcp

13. Displaying Kernel IP routing

Display Kernel IP routing table with netstat and route command

netstat -r

14. Showing Network Interface Transactions

Showing network interface packet transactions including both transferring and receiving packets with MTU size

netstat -i

15. Showing Kernel Interface Table

Showing Kernel interface table, similar to ifconfig command

netstat -ie

16. Displaying IPv4 and IPv6 Information

Displays multicast group membership information for both IPv4 and IPv6

netstat -g

17. Print Netstat Information Continuously

To get netstat information every few seconds, then use the following command, it will print netstat information continuously, say every few seconds.

netstat -c

 

18. Finding non-supportive Address

Finding un-configured address families with some useful information

netstat --verbose

 

19. Finding Listening Programs

Find out how many listening programs running on a port

netstat -ap | grep http

20. Displaying RAW Network Statistics

netstat --statistics --raw

That’s it, If you are looking for more information and options about the netstat command, refer to netstat manual docs or use the man netstat command to know all the information.

If we’ve missed anything in the list, please inform us using our comment section below. So, we could keep updating this list based on your comments.