Introduction
Monitoring network bandwidth usage is crucial for identifying bottlenecks, optimizing performance, and ensuring efficient use of resources. This guide covers various methods and tools for checking network bandwidth usage in Linux.
Prerequisites
- A Linux system with sudo privileges.
- Basic understanding of networking and Linux commands.
- Access to a terminal or SSH client.
Command-Line Tools for Bandwidth Monitoring
1. iftop
iftop displays real-time bandwidth usage per connection.
sudo yum install iftop -y # For RHEL/CentOS
sudo apt install iftop -y # For Ubuntu/Debian
sudo iftop
2. nload
nload shows incoming and outgoing traffic graphically in the terminal.
sudo yum install nload -y # For RHEL/CentOS
sudo apt install nload -y # For Ubuntu/Debian
nload
3. bmon
bmon provides a graphical view of bandwidth usage along with detailed statistics.
sudo yum install bmon -y # For RHEL/CentOS
sudo apt install bmon -y # For Ubuntu/Debian
bmon
4. vnstat
vnstat records bandwidth data over time for later analysis.
sudo yum install vnstat -y # For RHEL/CentOS
sudo apt install vnstat -y # For Ubuntu/Debian
sudo systemctl start vnstat
vnstat
GUI Tools for Bandwidth Monitoring
1. NetHogs
NetHogs provides a process-wise bandwidth usage report.
sudo yum install nethogs -y # For RHEL/CentOS
sudo apt install nethogs -y # For Ubuntu/Debian
sudo nethogs
2. Wireshark
Wireshark captures and analyzes network traffic for detailed monitoring.
sudo yum install wireshark -y # For RHEL/CentOS
sudo apt install wireshark -y # For Ubuntu/Debian
wireshark
Advanced Techniques
Using iperf
iperf measures network performance between two nodes.
sudo yum install iperf3 -y # For RHEL/CentOS
sudo apt install iperf3 -y # For Ubuntu/Debian
iperf3 -s # Run as server
iperf3 -c # Run as client
Using tc and ip Commands
The tc and ip commands offer advanced traffic control and bandwidth management capabilities.
sudo tc qdisc add dev eth0 root tbf rate 1mbit burst 32kbit latency 400ms
sudo tc -s qdisc show dev eth0
Troubleshooting
- Permission Denied Errors: Ensure you have sudo privileges.
- Tool Not Found: Verify the tool is installed using the package manager.
- No Traffic Data: Check the network interface name (e.g., eth0, ens33).
Tips and Best Practices
- Schedule bandwidth monitoring during peak hours for accurate data.
- Use lightweight tools like vnstat for continuous monitoring.
- Regularly analyze logs and historical data for trend analysis.
Conclusion
Monitoring network bandwidth usage in Linux is essential for maintaining performance and diagnosing network issues. This guide provides multiple tools and methods to suit different use cases.