nestat: Network statistics, routing tables, and interface statistics
August 9th, 2024 12:26 PM Mr. Q Categories: Command
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:*
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
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
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
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.