How to Install iftop on Linux Servers
How to Install iftop on Linux Servers
iftop is a real-time console-based network bandwidth monitoring tool, perfect for Linux server administrators who need to track network traffic in detail. It provides a user-friendly way to visualize bandwidth usage and identify which connections are consuming the most bandwidth. This guide will walk you through the process of installing and using iftop on Linux servers.
Prerequisites
To install and use iftop, you need:
A Linux server with root or sudo access.
An active internet connection to download packages.
Step 1: Update Your Server
Before installing any software, it’s always a good idea to update your system’s package lists to ensure you’re getting the latest versions.
On Ubuntu/Debian:
sudo apt update
On CentOS/RHEL:
sudo yum update
Step 2: Install iftop
iftop is available in most distribution repositories, making it easy to install using your default package manager.
For Ubuntu/Debian:
sudo apt install iftop
For CentOS/RHEL:
First, you need to enable the EPEL (Extra Packages for Enterprise Linux) repository:
sudo yum install epel-release
Then, install iftop:
sudo yum install iftop
For Fedora:
sudo dnf install iftop
For Arch Linux:
sudo pacman -S iftop
Step 3: Run iftop
Once installed, you can start monitoring your network traffic by simply running:
sudo iftop
You will see a real-time display of network traffic, showing active connections, the amount of data being transferred, and the bandwidth usage.
Step 4: Understanding the Output
iftop provides a simple, visual display of network traffic:
Left Column: IP addresses of the hosts sending and receiving traffic.
Right Columns: Shows the traffic in the last 2 seconds, 10 seconds, and 40 seconds.
Bottom: Displays the total bandwidth in/out and the limits of the network interface.
Step 5: Useful iftop Options
Here are a few helpful options to enhance your iftop usage:
Show Port Numbers: To display the port numbers alongside IP addresses, press p while iftop is running.
Show DNS Hostnames: If you prefer to see hostnames instead of IP addresses, press n to toggle this feature.
Limit Traffic Display by Network Interface: You can specify a particular network interface using the -i flag, for example:
sudo iftop -i eth0
Limit Bandwidth Scale: Press b to set a custom bandwidth scale that fits your network traffic.
Quit iftop: To exit iftop, press q.
Step 6: Customizing iftop Behavior
You can modify the default behavior of iftop by using command-line options. For instance:
Display traffic for a specific subnet:
sudo iftop -F 192.168.1.0/24
This will restrict the traffic displayed to the specified subnet.
Log Output to a File:
While iftop is designed for real-time monitoring, you can use tools like tee or redirect the output to a file for later analysis:
sudo iftop | tee iftop_output.txt
Thank you for visiting our site, you can check out our other related articles from the links below 🙂
How to Install and Use netstat on Linux
How to Install and Use TCPdump to Capture Packets on Linux
If you would like to improve yourself in server management, you can purchase a server from our site, experiment and improve yourself in an affordable and reliable environment. I wish you good luck.
Conclusion
iftop is a powerful yet lightweight tool for monitoring network traffic on Linux servers. Its real-time data display and easy-to-use interface make it an essential utility for administrators who need to keep a close eye on network activity. Whether you’re diagnosing network issues or just want a snapshot of your current bandwidth usage, iftop offers a quick and efficient solution.