Netstat (network statistics) is a command line utility that can be used to list out all the all the tcp, udp socket connections and the unix socket connections. So by checking an open port 80 you can confirm if a web server is running on the system or not. It is extremely helpful as far as network troubleshooting and performance measurement. netstat is a standout amongst the most essential system administration troubleshooting tool, letting you know what ports are open and whether any projects are listening on ports.
This tool is essential and much helpful for Linux network administrator and additionally system administrators to monitor and troubleshoot.
Listing all the LISTENING Ports
Show both listening and non-listening (TCP and UDP) sockets.
Show all “PID/Program Name” using netstat command. This is very useful while debugging to identify which program is running on a particular port.
# netstat -tp
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 64 node1:ssh 192.168.10.57:53291 ESTABLISHED 9296/sshd
Display Kernel IP routing
Display Kernel IP routing table with following command.
# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.10.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 0 0 0 eth0
default 192.168.10.19 0.0.0.0 UG 0 0 0 eth0
A list of flags is given below : A: Receive all multicast at this interface. B: OK broadcast. D: Debugging ON. M: Promiscuous Mode. O: No ARP at this interface. P: P2P connection at this interface. R: Interface is running. U: Interface is up. G: Not a direct entry.
Network Interface Transactions
Show network interface packet transactions including both transferring and receiving packets with MTU size using following command.
The RX and TX columns are described as follows : RX-OK: Correct packets received on this interface. RX-ERR: Incorrect packets received on this interface RX-DRP: Packets that were dropped at this interface. RX-OVR: Packets that this interface was unable to receive.
Similar definition is for the TX columns that describe the transmitted packets.
Display extended information on the interfaces (similar to ifconfig) using netstat