The netstat is a Terminal command which shows details regarding how our computer system is communicating with other network components.
Basically, the netstat command displays detailed statistics of every individual network connection,
network interfaces, routing tables, network protocols, and other network-specific information.
netstat helps us to deal with network issues and encourages network admins to have better performance measurements.
Prerequisites
- Access to the terminal
- Installed net-tools software package
Netstat Commands
1. Enlisting all ports (Listening ports and Non-listening ports)
To enlist all TCP ports, enter:
To enlist all UDP ports, enter:
2. Enlisting all Listening ports
To enlist all ports in the Listening state:
To enlist all TCP ports in Listening state:
To enlist all UDP ports in Listening state:
To enlist all UNIX ports in Listening state:
3. Display Statistics of Protocol
To show statistics of all protocols:
To show statistics of TCP protocol:
To show statistics of UDP protocol:
4. Display Process ID/Program ID (PID) and Program Name
This command will display all the processes/programs running on corresponding ports.
5. Display netstat Continuously
6. To show non-supportive Address families
After running the above command, you will observe some lines at the end which read as:
7. Show Kernel IP Routing Table
8. Enlist all Network Interfaces
To display detailed information about each network interface, run the following command: