netstat (network statistics) is a command-line network tool that displays network connections for Transmission Control Protocol (both incoming and outgoing). It is also monitor routing tables, number of network interface and protocol statistics. netstat is available on Linux operating systems.
We can use it for finding problems in the network and to determine the amount of traffic on the network as a performance measurement. It is very useful tool for monitoring and diagnosing connection problems.
In case, you are unable to use netstat command, use below command to install it.
yum install -y net-tools
Now it is installed and ready to use.
Below are some useful commands to monitor network connections.
Display network interfaces
You can run below command to see all available network interfaces on the server.
Print all TCP and UDP listening Ports
Now, if you want to see all listening ports on the server, use below command.
netstat -a | more
List only TCP Ports connections
so, issue following command to see all TCP connections.
Show only UDP Ports connections
Then, run following command to see all UDP connections.
List services names with PID
Then, see all services with their process ID’s
Display kernel routing information
Use below command so you can see kernel routing information.
Print Netstat Information Continuously
Finding Listening service
Note: Replace ssh with your service name.
netstat -ap | grep ssh
That’s it, to get more information and options about netstat command read manual for netstat command using “man netstat” command