⁣⁣netstat command (Network statistics)

Description

The "netstat" command allows to monitor network connections, network packets statistic for each protocol, to display routing tables and statistics for network interfaces.

Syntax:

net -r print routing table
net -i [clear] print interface table
net -s print IP statistics
net -s{rut} print protocol statistics (raw,udp,tcp)

Parameters

Parameter
Description

-r

Displays the content of the system routing tables.

Flags for specific routes have the following meaning:

  • "U" – this routing table element is currently active.

  • "H" – this route leads to a host. If this flag is not set, the route goes to a network.

  • "D" – this route has been created using the "icmp redirect" protocol.

  • "M" – this route has been modified using the "icmp redirect" protocol.

  • "G" – this route is connected to a host. If this flag is not set, it is considered that the route destination is directly connected.

  • "S" – it's a static route, set by the operator using a "route add" command.

  • "1" – a pseudostatic route, set as a result of a "rip static" command.

  • "L" – a route points to a directly connected host (for such a route an APR request may be performed).

  • "C" – when using this route, more specific routes may be created (e.g. using the "L" flag).

-i [clear]

Displays an information about each network interface in the system.

  • "clear" – resets a statistic of inbound / outbound packets and errors.

-s{rut}

Displays statistics for IP and ICMP packets.

  • "r" – if added, statistic of RAW protocol packets is displayed.

  • "u" – statistic of UDP protocol packets is displayed.

  • "t" – statistic of TCP protocol packets is displayed.

Examples

Display the content of the system routing tables using the "-r" parameter.

Routing tables
Destination        Gateway            Flags     Refs     Use  Interface
default            192.168.103.1      UGS         1       47  svi1
10.10.10.0/24      link#2             UC          0        0  eth0
127.0.0.1          127.0.0.1          UH          2       26  lo0
192.168.103.0/24   link#6             UC          0        0  svi1
192.168.103.1      6c:3b:e5:51:e3:8d  UHL         1        0  svi1
192.168.103.20     bc:ee:7b:8d:32:65  UHL         0     1743  svi1
192.168.103.243    08:00:27:54:47:bf  UHL         1    17257  svi1
224.0.0.0/8        127.0.0.1          UGS         0        0  lo0

Reset the statistic of packets and display the information about network interfaces using the "netstat -i [clear]" command.

Use the "-s" parameter to display packet statistic.

Display statistic of UDP protocol packets using the "netstat -su" command.

Last updated