Display the network statisticsDescription
The "netstat" command allows to monitor network connections, network packets statistic for each protocol, to display routing tables and statistics for network interfaces.
Syntax:
netstat -r
netstat -i
Displays the contents of different system data pertained to network parameters.
“-r” parameter displays system routing tables:
...
title | Figure - “-r” parameter output |
---|
...
Code Block |
---|
|
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
Parameters | Description |
---|
-r
| Displays the content of the system routing tables.
Flags for specific routes have the following meaning: |
...
- – 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"
|
...
...
...
[clear] | Displays an information about each network interface in the system |
...
title | Figure - “-i” parameter output |
---|
...
. - "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. Code Block |
---|
| 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. Code Block |
---|
| Name Network Address Ipkts Ierrs Opkts Oerrs
lo0 Link: 0 0 0 0
lo0 127.0.0.1/32 127.0.0.1
eth0 Link: 00043503f7dd 0 0 0 0
eth0 10.10.10.0/24 10.10.10.14
eth1 Link: 00043513f7dd 0 0 0 0
eth1 none none
rf5.0 Link: 00043523f7dd 0 0 0 0
rf5.0 none none
null0* Link: 0 0 0 0
svi1 Link: 02043503f7dd 0 0 0 0
svi1 192.168.103.0/24 192.168.103.37 |
|
Use the "-s" parameter to display packet statistic. Code Block |
---|
| IP statistic:
ips_total 8584161 (total packets received)
ips_badsum 0 (checksum bad)
ips_tooshort 0 (packet too short)
ips_toosmall 0 (not enough data)
ips_badhlen 0 (ip header length < data size)
ips_badlen 0 (ip length < ip header length)
ips_fragments 0 (fragments received)
ips_fragdropped 0 (frags dropped (dups,ipstat. out of space))
ips_fragtimeout 0 (fragments timed out)
ips_forward 0 (packets forwarded)
ips_cantforward 2496172 (packets rcvd for unreachable dest)
ips_redirectsent 0 (packets forwarded on same net)
ips_noproto 0 (unknown or unsupported protocol)
ips_delivered 6087989 (datagrams delivered to upper level
ips_localout 335787 (total ip packets generated here)
ips_odropped 0 (lost packets due to nobufs,ipstat. etc.)
ips_reassembled 0 (total packets reassembled ok)
ips_fragmented 0 (datagrams sucessfully fragmented)
ips_ofragments 0 (output fragments created)
ips_cantfrag 0 (don't fragment flag was set,ipstat. etc.)
ips_badoptions 0 (error in option processing)
ips_noroute 0 (packets discarded due to no route)
ips_badvers 0 (ip version != 4)
ips_rawout 17401 (total raw ip packets generated)
ips_badfrags 0 (malformed fragments (bad length))
ips_rcvmemdrop 0 (frags dropped for lack of memory)
ips_toolong 0 (ip length > max ip packet size)
ICMP Staticstic:
icps_error 0 ( # of calls to icmp_error )
icps_oldshort 0 ( no error 'cuz old ip too short )
icps_oldicmp 0 ( no error 'cuz old was icmp )
icps_badcode 0 ( icmp_code out of range )
icps_tooshort 0 ( packet < ICMP_MINLEN )
icps_checksum 0 ( bad checksum )
icps_badlen 0 ( calculated bound mismatch )
icps_reflect 0 ( number of responses )
icps_bmcastecho 0 ( rejected broadcast icmps ) |
|
Display statistic of UDP protocol packets using the "netstat -su" command. Code Block |
---|
| UDP statistic:
udps_ipackets 5878277
udps_opackets 11019
udps_hdrops 0
udps_badsum 0
udps_badlen 0
udps_noport 0
udps_fullsock 0
udps_pcbhashmiss 17511
0.0.0.0:0 snmp
0.0.0.0:161 snmp
0.0.0.0:22534 trap |
|