39 C
Jaipur
Sunday, April 11, 2021

Netstat Command in Linux – Linux Hint

Must read

Netstat is a command-line tool used by system administrators to evaluate network configuration and activity. The term Netstat is results from network and statistics. It shows open ports on the host device and their corresponding addresses, the routing table, and masquerade connections.

The purpose of this post is to show you how to install and configure different Netstat commands in Linux.

Installing Net-tools on Linux:

Netstat is part of a package named net-tools. You can get the net-tools package on Ubuntu with the command:

$ sudo apt install net-tools

Check Version of Netstat:

Upon installation, check the installed version of Netstat:

D:AqsaNestat Command in LinuxNestat Command in Linuximagesimage3 final.png

Netstat command in Linux:

Display Routing table:

Netstat command shows the routing table detail on the terminal. If you wish to see the routing table, use the –nr flag with Netstat; it shows the kernel routing table in the same way that route does. Use the below command:

Instead of using symbolic address names, the -nr option allows Netstat to print addresses divided by dots

Display interface statistics:

Using the ‘-i’ flag or option with Netstat will show statistics for the currently configured network interfaces.

D:AqsaNestat Command in LinuxNestat Command in Linuximagesimage5 final.png

If the “–a” flag is also used with “-i”, the command prints all of the kernel interfaces.

D:AqsaNestat Command in LinuxNestat Command in Linuximagesimage4 final.png

Display Network connection:

To view active or passive sockets, Netstat has a range of options. Active TCP, UDP, RAW, and Unix socket connections are specified by the –t, –u, –w, and –x options, respectively.

Type on your terminal:

D:AqsaNestat Command in LinuxNestat Command in Linuximagesimage7 final.png

Display Network Services:

Run the following command to see a list of networks, their current states, and their associated ports:

D:AqsaNestat Command in LinuxNestat Command in Linuximagesimage6 final.png

Display all the listening port of TCP and UDP connection:

You can see all TCP and UDP ports by using the command:

D:AqsaNestat Command in LinuxNestat Command in Linuximagesimage8 fial.png

Display TCP Port Connection:

To get the list of only TCP (Transmission Control Protocols) port connection, use the following command:

Display UDP Port Connection:

To see UDP (User Diagrams Protocols) port connection, use the command:

Display all Listening Connection:

List all the active connection by using the “-l” flag with Netstat:

Display all TCP Listening port:

We can get the list of all active listening TCP ports by using the –‘lt’ flag as follows:

Display all UDP listening port:

We can get the list of all active listening UDP ports by using ‘–lu’ option:

Display all Unix Listening port:

Display the list of all active listening UNIX ports by using –lx:

Showing Statistics by Protocol:

Displays protocol-specific statistics. The TCP, UDP, ICMP, and IP protocol statistics are displayed by default. A set of protocols can be defined using the -s option:

D:AqsaNestat Command in LinuxNestat Command in Linuximagesimage15 final.png

Showing Statistics by TCP Protocol:

Display the list of only TCP protocols by using the ‘–st’ option with Netstat:

Showing Statistics by UDP Protocol

Display the list of only UDP protocols by using the ‘–su’ option with Netstat:

D:AqsaNestat Command in LinuxNestat Command in Linuximagesimage17 final.png

Conclusion:

Netstat is a valuable method for tracking network activity and configuration. It is, in reality, a jumbled-up collection of several resources. In this post, we have demonstrated that how to manage network connections using the Netstat command.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article