netstat command in Linux with examples

Hello everyone In this Article we are going to learn about how we can troubleshoot the networking in Linux using the netstat command with examples  in a very simple and easy step-by-step approach

Yellow Fishing Boat Blog Banner 66

netstat command

The netstat (network statistics )command is a useful tool for monitoring network connections for both incoming and outgoing packets as well as statistics viewing routing tables and much more.

The netstat is the tool to monitor and troubleshoot their network-related problems and determine network traffic performance in efficent way .

How to list all TCP & UDP Connection

To list all of the TCP & UDP connections then we can use ( -a ) option in the netstat command

# netatat -a
Screenshot 1 8

How to list all TCP Connections

To list all of the TCP connections then we can use ( -at ) option in the netstat command.

# netstat -at
Screenshot 2 4

How to list all UDP Connection

To list all of the UDP connections then we can use the ( -au ) option in the netstat command.

Screenshot 3 6

How to list all listening Connections

To list all of the listening connections then we can use ( -l ) option in the netstat command.

# netstat -l
Screenshot 4 6

How to list all TCP listening ports

To list all of the listening ports only for TCP then we can use the ( -lt ) option in the netstat command.

# netstat -lt
Screenshot 5 5

How to list all UDP listening ports

To list all of the listening ports only for UDP then we can use ( -lu ) option in the netstat command.

# netstat -lu
Screenshot 6 5

How to list all Kernel Routing tables

To list all of the Kernel Routing tables then we can use ( -r ) option in the netstat command.

# netstar -r
Screenshot 7 7

How to list all service name with Pid

To list all of the service names with the PID then we can use the ( -tp ) option in the netstat command.

# netstat -tp
Screenshot 8 8

How to get the Status of all of the ports with specific time Interval

To get the status of all of the ports with a specific time Interval then use (-ac ) option with the time interval we need in seconds in the netstat command.

# netstat -ac 10
Screenshot 9 5

How to list all IPv4 and IPV6 Status

To list all IPv4 and IPv6 status then we can use (-g ) option in the netstat command.

# netstat -g
Screenshot 10 4

How to List the status on basics of the TCP/UDP Protocol

When we add ( -s ) option in the netstat command then we can List the Information on basics of the Protocol

# netstat -s
Screenshot 11 4

How to List the status on basics of the TCP protocol

When we add ( -st ) option in the netstat command then we can List the Information on basics of the TCP Protocol

# netstat -st
Screenshot 12 2

How to List the status on basics of the UDP protocol

When we add ( -su ) option in the netstat command then we can List the Information on basics of the UDP Protocol

# netstat -su
Screenshot 13 4

How to List all the ports in one command

To list all the active TCP / UDP ports in one with their IP address then we can use ( –tunlp) option in netstat command

-t – For TCP

-u – For UDP

-n – To List the information in the form of IP address

-l – To list all the listening ports

-p – To list all the ports

# netstat -tunlp
Screenshot 14 4

Conclusion

If you want to learn Linux in the most simple language then please click on this link.

If you want to see the man page of netstat command online then click on this link

This is the complete knowledge of how we can troubleshoot the network in Linux using netstat command if you have any doubts please feel free to comment below. Please don’t forget to join our email subscription to get the latest updates on DevOps Articles.

Leave a Comment