Successfully pass the free certification exam at IW Academy and become an Infinet Certified Engineer.
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
Parameters | Description |
---|---|
-r | Displays the content of the system routing tables. Flags for specific routes have the following meaning:
|
-i [clear] | Displays an information about each network interface in the system.
|
-s{rut} | Displays statistics for IP and ICMP packets.
|
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. 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. 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. 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 |