Iftop
Iftop: Real-time Network Bandwidth Monitoring
iftop is a powerful command-line utility for Linux that displays network bandwidth usage on an interface, broken down by host. It provides a real-time view of network traffic, making it invaluable for identifying network bottlenecks, monitoring resource consumption, and troubleshooting connectivity issues. Unlike traditional network monitoring tools, iftop focuses on displaying the connections between hosts and the amount of bandwidth each connection is consuming.
Understanding Iftop Command Usage
The basic usage of iftop involves simply typing the command in your terminal. However, numerous options allow you to customize its output and functionality for specific monitoring needs.
# Display bandwidth usage on the default interface
iftop
# Display bandwidth usage on a specified interface
iftop -i eth0
# Show or hide DNS hostnames for easier identification
iftop -n # Show network traffic without resolving hostnames
# Limit the display to IPV4 or IPV6 traffic
iftop -4 # Show only IPV4 traffic
iftop -6 # Show only IPV6 traffic
# Set the screen update interval to 5 seconds and use text interface
iftop -t -s 5
# Display bandwidth in bits instead of bytes for finer granularity
iftop -b
# Adjust the sort order of hosts for better analysis
iftop -o source # Sort by source address
iftop -o destination # Sort by destination address
iftop -o both # Sort by both
# Display cumulative usage since the tool started
iftop -c
# Use a custom filter code, e.g., to monitor specific port traffic
iftop -f "port 80" # Show only HTTP traffic
# Show only a specific number of lines to focus on top consumers
iftop -N 10 # Display the first 10 lines only
# Freeze the current display to observe a snapshot
iftop -F
Advanced Iftop Features and Filtering
iftop supports advanced filtering using Berkeley Packet Filter (BPF) syntax, allowing you to precisely target the traffic you want to monitor. This is particularly useful in busy network environments where you need to isolate specific services or protocols.
Iftop vs. Other Network Tools
While tools like netstat and tcpdump provide valuable network information, iftop excels at presenting a clear, real-time overview of bandwidth consumption per host. Its intuitive display makes it a preferred choice for quick network performance checks.
These are some common use cases for using iftop to display bandwidth usage by host on a network interface. For more detailed information and advanced configurations, refer to the official iftop man pages.
For further learning on network protocols and analysis, consider these resources: