Analyzing Network Interface Statistics
In this step, you will learn how to view statistics for your network interfaces. These statistics provide valuable information about the performance and usage of your network interfaces.
Viewing Interface Statistics
Let's use netstat
to display statistics for all network interfaces:
netstat -i > interface_stats.txt
In this command:
-i
displays a table of all network interfaces
> interface_stats.txt
saves the output to a file
Now let's examine the contents of the file:
cat interface_stats.txt
You should see output similar to this:
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 123456 0 0 0 98765 0 0 0 BMRU
lo 65536 789 0 0 0 789 0 0 0 LRU
Understanding Network Interface Statistics
The output provides important statistics about each network interface:
-
Iface
: The name of the network interface
eth0
: Typically the first Ethernet interface
lo
: The loopback interface used for local connections
-
MTU
: Maximum Transmission Unit - the largest packet size that can be transmitted
- Standard Ethernet typically uses 1500 bytes
- The loopback interface typically has a larger MTU (65536)
-
RX-OK
: Number of packets received without errors
-
RX-ERR
: Number of packets received with errors
-
RX-DRP
: Number of received packets dropped
-
RX-OVR
: Number of received packet overruns
-
TX-OK
: Number of packets transmitted without errors
-
TX-ERR
: Number of packets transmitted with errors
-
TX-DRP
: Number of transmitted packets dropped
-
TX-OVR
: Number of transmitted packet overruns
-
Flg
: Flags indicating the interface status
B
: Broadcast address set
M
: Multicast enabled
R
: Interface is running
U
: Interface is up
These statistics help you monitor network performance and identify potential issues, such as packet loss or transmission errors.
Additional Network Statistics Commands
For a more comprehensive view of network statistics, you can also use:
netstat -s | head -20 > protocol_stats.txt
This command displays protocol statistics for TCP, UDP, IP, ICMP, and other protocols. We're using head -20
to limit the output to the first 20 lines for readability.
Let's view this file:
cat protocol_stats.txt
This provides detailed statistics about how each protocol is performing, helping you identify potential network issues at the protocol level.