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:
Check Version of Netstat:
Upon installation, check the installed version of Netstat:
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.
If the “–a” flag is also used with “-i”, the command prints all of the kernel interfaces.
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:
Display Network Services:
Run the following command to see a list of networks, their current states, and their associated ports:
Display all the listening port of TCP and UDP connection:
You can see all TCP and UDP ports by using the command:
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:
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:
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.