Netstat Commands To Manage Network in Linux

Compilation with different Netstat commands to manage a network in Linux

When handling and managing Linux operating systems, one of the best practices we can take is to know in detail the commands that facilitate the task of administration and control in a much simpler way.

One of these commands is netstat, (network statistics – network statistics) which is a command line tool that allows us to monitor incoming and outgoing network connections, as well as view routing tables, interface statistics, etc.

The netstat command is available on all Unix operating systems and is also available on Windows operating systems and is practical regarding troubleshooting network problems and measuring performance.

TheLinuxCode brings today some of the most useful netstat commands for better control and supervision.

List All Listening Ports of TCP & UDP Connections

This task can be done using the option using netstat -and thus listing all the ports (TCP and UDP) in listening state:

netstat -a | more

There we will see the type of protocol, the local address, the remote address and its current status.

List Connections of TCP Ports

If we wish to list only TCP (Transmission Control Protocol) connections, it will be necessary to use the netstat -at parameter:

netstat -at

We can see in detail the information of those ports.

List Connections of UDP Ports

If it is necessary to deploy all UDP port connections (User Datagram Protocol) we must use the netstat -au parameter:

netstat -au

List All Connections in Listening Status

With netstat it is possible to list all connections of active listening ports with the netstat -l parameter.

netstat -l

List All TCP Ports Listener

If it is required to list all active listening TCP ports, we can do it through the netstat -lt option.

netstat -lt

List All UDP Ports Listener

If you want to list all active listening UDP ports, it will be possible to do so using the netstat -lu option.

netstat -lu

List All UNIX Ports Listener

The netstat command allows us to list all active UNIX listener ports using the netstat -lx parameter:

netstat -lx

Display Statistics By Protocol

Netstat offers us the option to display statistics by a protocol.

By default, statistics for the TCP, UDP, ICMP and IP protocols will be displayed. The -s parameter can be used to specify a set of protocols.

We can see detailed information of each protocol of the system.

Display TCP Protocol Statistics

If we want to display only TCP protocol statistics using netstat, we can use the netstat -st parameter:

netstat -st

DIsplay UDP Protocol Statistics

If, on the other hand, we wish to visualize the statistics of the UDP protocol, we must execute netstat -su:

netstat -su

Display Service Names with Linux PID

With the option netstat -tp “PID / Program Name” will appear, which displays the name of the service with its PID number.

netstat -tp

Display Promiscuous Mode

When displaying the Promiscuous mode with the -ac parameter, netstat prints the selected information or updates the screen every five seconds. The default screen is updated every second.

netstat -ac 5 | grep tcp

Display IP Routing of the Linux Kernel

This option allows us to display the IP routing table of the kernel with the command netstat and route (-r).

netstat -r

Display Linux Network Interface Transactions

Thanks to this option it will be possible to deploy the packet transactions of the network interface including both the transfer and the reception of packages with MTU size, for this we will execute the following:

netstat -i

Display Linux Kernel Interface Table

This option is similar to the ifconfig command, nd displays the kernel interface table. For its use we will execute the following:

netstat -ie

Display IPv4 & IPv6 Info

Thanks to this parameter we will see formation of belonging to multicast groups for IPv4 and IPv6. Its parameter is:

netstat -g

Print Netstat Info Continuously

To obtain netstat information every defined time it will be possible to use the following command which will print netstat information continuously:

netstat -c

To finish the display, we will use the key combination Ctrl + C.

Find A Linux Non-support Address

This option allows you to find families of non-configured addresses with useful information.

netstat --verbose

Show Linux Listening Programs

With this option it is possible to validate how many listening programs are executed in a defined port, the syntax to use is, for example, for http:

netstat -ap | grep http

Display Linux RAW Network Statistics

If we want to display the RAW network statistics we can do it using the following command:

netstat --statistics –raw

We have these options to manage various values and parameters of the network using netstat in Linux distros in a practical way.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *