Last edited 5 years ago

Netstat

1. Article purpose

This article provides the basic information needed to start using the Linux tool: netstat [1].

2. Introduction

The following table provides a brief description of the tool, as well as its availability depending on the software packages:

Yes: this tool is either present (ready to use or to be activated), or can be integrated and activated on the software package.

No: this tool is not present and cannot be integrated, or it is present but cannot be activated on the software package.

Tool STM32MPU Embedded Software distribution STM32MPU Embedded Software distribution for Android™
Name Category Purpose Starter Package Developer Package Distribution Package Starter Package Developer Package Distribution Package
netstat Monitoring tools netstat[1] prints network connections, routing tables, interface statistics, masquerade connections, and multicast membership information. Yes Yes Yes Yes Yes Yes

3. Installing the trace and debug tool on your target board

3.1. Using the STM32MPU Embedded Software distribution

netstat is installed by default and ready to be used with all STM32MPU Embedded Software Packages.

It comes through the busybox:

 which netstat | xargs ls -la
/bin/netstat -> /bin/busybox.nosuid

3.2. Using the STM32MPU Embedded Software distribution for Android™

netstat is installed by default and ready to be used with all STM32MPU Embedded Software Packages for Android™.

It comes with the toybox:

 which netstat | xargs ls -la
/system/bin/netstat -> toybox

4. Getting started

Here are basic commands to start with netstat:

  • Display kernel routing information
 netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         10.99.3.254     0.0.0.0         UG        0 0          0 eth0
10.99.0.0       0.0.0.0         255.255.252.0   U         0 0          0 eth0
10.99.3.254     0.0.0.0         255.255.255.255 UH        0 0          0 eth0
  • List out listening-only connections
 netstat -tnl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       
tcp        0      0 0.0.0.0:19999           0.0.0.0:*               LISTEN      
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      
tcp        0      0 10.99.1.237:53          0.0.0.0:*               LISTEN      
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      
tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN      
tcp        0      0 0.0.0.0:1534            0.0.0.0:*               LISTEN      
tcp        0      0 :::19999                :::*                    LISTEN      
tcp        0      0 :::5355                 :::*                    LISTEN      
tcp        0      0 :::53                   :::*                    LISTEN      
tcp        0      0 :::22                   :::*                    LISTEN

5. To go further

Additional documentation is available on Internet about netstat. See References.

Refer to Linux® man page[1] for more details on command options.

6. References


  • Useful external links
Document link Document Type Description
netstat (wikipedia.org) Standard wikipedia.org
netstat examples User Guide binarytides.com
netstat main commands User Guide geekflare.com