Enhancing Skills

nestat: Network statistics, routing tables, and interface statistics

Command: netstat

Used to display network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. It helps monitor network activity and diagnose network issues.


Sample Command and Output:

$ netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:22             0.0.0.0:*               LISTEN
tcp        0      0 192.168.1.10:22        93.184.216.34:49234     ESTABLISHED
udp        0      0 0.0.0.0:68             0.0.0.0:*                          
udp        0      0 192.168.1.10:123       0.0.0.0:*                          
Copy

001$ netstat -a

002Active Internet connections (servers and established)

003Proto Recv-Q Send-Q Local Address Foreign Address State

004tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN

005tcp 0 0 192.168.1.10:22 93.184.216.34:49234 ESTABLISHED

006udp 0 0 0.0.0.0:68 0.0.0.0:*

007udp 0 0 192.168.1.10:123 0.0.0.0:*

Description:

  • netstat -a: Displays all active network connections and listening ports. Includes details such as protocol (Proto), local and foreign addresses, and connection state.

Additional Commands and Sample Outputs:

  • netstat -r: Display the routing table. Sample Command and Output:
  $ netstat -r
  Kernel IP routing table
  Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
  192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
  default         192.168.1.1     0.0.0.0         UG    100    0        0 eth0
Copy

001 $ netstat -r

002 Kernel IP routing table

003 Destination Gateway Genmask Flags Metric Ref Use Iface

004 192.168.1.0 * 255.255.255.0 U 0 0 0 eth0

005 default 192.168.1.1 0.0.0.0 UG 100 0 0 eth0

Description:

  • netstat -r: Shows the routing table. It includes the destination, gateway, netmask, and interface for each route.
  • netstat -i: Display network interface statistics. Sample Command and Output:
  $ netstat -i
  Kernel Interface table
  Iface   MTU  RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
  eth0   1500  1234      0      0      0   567      0      0      0 BMRU
  lo     65536  123      0      0      0    123      0      0      0 LRU
Copy

001 $ netstat -i

002 Kernel Interface table

003 Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg

004 eth0 1500 1234 0 0 0 567 0 0 0 BMRU

005 lo 65536 123 0 0 0 123 0 0 0 LRU

Description:

  • netstat -i: Displays statistics for each network interface, including the number of packets received and transmitted, errors, and drops.
  • netstat -s: Display network statistics by protocol. Sample Command and Output:
  $ netstat -s
  Ip:
      1234 total packets received
      567 packets forwarded
      12 packets not forwardable
      7898 total packets sent
  Icmp:
      123 ICMP messages received
      34 ICMP messages sent
Copy

001 $ netstat -s

002 Ip:

003 1234 total packets received

004 567 packets forwarded

005 12 packets not forwardable

006 7898 total packets sent

007 Icmp:

008 123 ICMP messages received

009 34 ICMP messages sent

Description:

  • netstat -s: Provides statistics for various network protocols, such as IP and ICMP, including the number of packets received and sent.

This command provides a comprehensive view of the system’s network activity, interfaces, and routing information.


Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.