
Bandwidth Monitoring with iftop: A Real-Time CLI Guide
Table of Contents
- What This Guide Is About (and Why You Need It)
- The Dramatic Bandwidth Mystery
- The Real Problem: What’s Eating Your Bandwidth?
- How Does
iftop
Work? (Under the Hood) - Tree of Use Cases & Benefits
- Setup
iftop
in 3 Minutes or Less - Step-By-Step Guide & Practical Examples
- Real-Talk Mini Glossary
- Comic Metaphor: Comparison Table
- Beginner Mistakes, Myth Busting, and Similar Tools
- “Use This If…” Decision Tree
- Interesting Facts and Unconventional Hacks
- Automation, Scripting, and Cool Scripts
- Fictionalized Admin Story
- Conclusion & Wrap-Up
What This Guide Is About (and Why You Need It)
If you’re running a VPS, dedicated box, cloud instance, or Docker host, you know network traffic isn’t just numbers: it’s your uptime, your wallet, and sometimes, your sanity. This guide is all about bandwidth monitoring in real-time, using the legendary CLI tool iftop
. We’ll get you from zero to packet-ninja in minutes—no fluff, just the stuff you actually need.
Why care? Because whether you’re a coder, DevOps wrangler, sysadmin, or just the person everyone yells at when the server “feels slow,” understanding where your bandwidth goes can save you from downtime, overage bills, or angry clients. iftop is the secret x-ray specs that show you what’s really happening, live.
This isn’t just a manual; it’s the geeky, practical, slightly opinionated guide you wish you’d had before your next network panic.
The Dramatic Bandwidth Mystery
It’s 2am. Your server’s load is fine, but your apps are crawling. The network graph looks like a mountain range, and your host says you’re about to hit your bandwidth cap. But what is eating your pipes? Is it a runaway process? A hacker? Or that one colleague streaming 4K cat videos over SSH tunnels again?
Panic not: iftop
is here to put on its detective hat and show you, in real time, exactly who and what is hogging your precious bandwidth.
The Real Problem: What’s Eating Your Bandwidth?
- Bandwith spikes—but you have no idea why.
- VPS/Dedicated/Cloud plans with data caps (don’t want surprise bills!).
- Security: Is someone exfiltrating data?
- Performance: Is a single user or process tanking your whole network?
Traditional tools like top
or htop
only show CPU and memory. Standard network graphs show totals, but not who is talking to whom. You need a tool like iftop—think of it as top for network traffic.
How Does iftop
Work? (Under the Hood)
iftop
listens to network traffic on your chosen interface (like eth0
, ens18
, or docker0
) using the libpcap
library—the same low-level magic that powers tcpdump
and wireshark
. It captures packet headers (not payloads, so it’s lightweight), and builds up a live table of “which remote IP is talking to which local IP, and how much data is flowing.”
- It shows source → destination pairs, bandwidth usage over 2s/10s/40s averages, and totals.
- It’s read-only—it won’t mess with traffic, just observe.
- No need to install agents or sign up for anything. One command, instant results.
The result: a live, interactive, sorted display of network traffic—think “Matrix code” but with real meaning.
Tree of Use Cases & Benefits
-
Diagnose Slowdowns:
- Spot a single IP or process hogging the line
- Find botnet or DDoS traffic in seconds
-
Security & Auditing:
- See if sensitive data is leaking out
- Check for weird, unexpected remote connections
-
Cost Control:
- Detect bandwidth overages before they hurt
- Monitor on-the-fly during big deploys or backups
-
Debugging & Optimization:
- Find chatty apps, misconfigured services, or forgotten cron jobs
- Instant feedback when tuning firewall rules, VPNs, or proxies
-
Cool Geek Tricks:
- Watch live traffic on a Docker bridge
- Monitor VPN tunnels or overlay networks
Setup iftop
in 3 Minutes or Less
Ready to get your network “x-ray vision”? Here’s how to install iftop
on the most common Linux distros (and yes, it works in Docker containers and on cloud VMs too):
- Debian/Ubuntu:
sudo apt update && sudo apt install iftop
- CentOS/RHEL/Fedora:
sudo yum install iftop
or
sudo dnf install iftop
- Alpine (great for containers!):
apk add iftop
- macOS (via Homebrew):
brew install iftop
No kernel modules, no reboot, no config files. iftop
is a single, small binary.
Step-By-Step Guide & Practical Examples
-
Find your network interface:
ip addr
Look for something like
eth0
,ens18
,wlan0
, ordocker0
for containers. -
Run
iftop
(as root or with sudo):
sudo iftop -i eth0
Replace
eth0
with your actual interface name. -
Interact with the live UI:
- q: quit
- h: help (shows keys)
- t: toggle display types
- S: toggle source host display
- D: toggle destination host display
- p: show port numbers
- f: filter (like grep for traffic)
-
Pro tip: Only want to see traffic for a specific port (e.g. web server)?
sudo iftop -i eth0 -F 0.0.0.0/0:80
-
Want to log output for later?
sudo iftop -i eth0 -t > bandwidth.log
(-t for text, non-interactive mode)
Tip: Combine iftop
with VPS or dedicated server hosting and spot bandwidth hogs before they cost you!
Real-Talk Mini Glossary
- Packet: A little chunk of data zipping across your network—think “network Lego brick.”
- Interface: The “doorway” (like eth0) for packets to enter/exit your server.
- Bandwidth: The speed/amount of data passing through—like water flow in a pipe.
- Source/Destination: Who sent it / who’s getting it. (Not always YOU!)
- RX/TX: Receive (incoming) / Transmit (outgoing) data.
- Filter: A way to focus only on some traffic (like “show me only port 22/SFTP”).
- libpcap: The secret sauce that reads network traffic; powers tcpdump, wireshark, and iftop.
Comic Metaphor: Comparison Table
Tool | Comic Persona | Strengths | Weaknesses |
---|---|---|---|
iftop |
The Traffic Detective 🕵️ | Live, real-time, easy to read, CLI, dead simple | Not historical, no per-process data, no pretty graphs |
nload |
The Speedometer 🚗 | Shows total up/down, nice graphs | No detail on who/what, just totals |
vnStat |
The Accountant 👓 | Long-term stats, hourly/daily/monthly totals | No real-time, not live, not interactive |
netstat / ss |
The Librarian 📚 | List all connections/ports, precise | No bandwidth info, not live-updating |
Wireshark |
The Mad Scientist 🧪 | Deep packet analysis, decode everything | Needs GUI, too much info for quick checks |
Comic verdict: iftop
is the Sherlock Holmes for live bandwidth sleuthing. If you want pretty graphs for your boss or need months of history, check out vnStat
or nload
. If you need to debug packet-level protocol bugs, Wireshark is your mad scientist.
Beginner Mistakes, Myth Busting, and Similar Tools
-
Myth 1: “iftop will slow down my server!”
Reality: Unless you’re capturing traffic on a gigabit interface at 100% load,iftop
is super lightweight (just headers, not payloads). -
Myth 2: “iftop is the same as top for processes.”
Reality:iftop
shows network bandwidth by connection/IP, not by process. If you want per-process, trynethogs
. -
Mistake 1: “Why is iftop empty?”
Tip: You probably chose the wrong interface (happens all the time on VMs/Cloud). Tryip addr
and look for the one with your public IP. -
Mistake 2: “iftop isn’t showing hostnames!”
Tip: It tries to reverse-resolve IPs by default (can be slow or misleading). Use -n to disable DNS lookups for speed:sudo iftop -n -i eth0
-
Similar tools:
nload
,vnstat
,nethogs
(per-process!),iptraf
,bmon
Want to try another bandwidth tool? Check out these non-commercial projects:
- nload – cool ASCII graphs!
- vnstat – for stats over days/months.
- nethogs – shows traffic by process, not just connection.
“Use This If…” Decision Tree
Confused which tool to use? Here’s a (slightly silly) flowchart:
👀 Do you want to see live bandwidth, by IP/connection? ⬇️ Yes | ➡️ Do you need per-process info? ⬇️ No ➡️ Use iftop! ⬇️ Yes ➡️ Use nethogs. ⬇️ No | ➡️ Need pretty graphs? ⬇️ Yes ➡️ Use nload. ⬇️ No ➡️ Want long-term stats? ⬇️ Yes ➡️ vnstat. ⬇️ No ➡️ Use netstat or ss for connections only.
Interesting Facts and Unconventional Hacks
- Works in containers: You can run
iftop
inside a Docker container to debug traffic ondocker0
or overlay networks. (Try--net=host
for full access.) - Low-level but safe:
iftop
only reads headers, so it can’t “sniff passwords” but can show weird connections in/out. - Combine with firewall tuning: Run
iftop
in one terminal, and block/allow rules in another—see effects instantly. - Automation: You can wrap
iftop -t
in scripts to alert on high bandwidth or log usage for later. - Great for cloud: Most cloud hosts don’t give you fine-grained bandwidth stats—
iftop
gives you live data for free. - Fun stat:
iftop
was written in 2002, and it’s still a top download for server admins. It’s tiny (~100KB) and runs everywhere.
Automation, Scripting, and Cool Scripts
Want to get an alert if outgoing bandwidth exceeds 100Mbps? Here’s a one-liner using iftop
and awk
:
sudo iftop -i eth0 -t | grep "=>" | awk '{print $9}' | grep -E '[0-9]+\.[0-9]+[MG]b/s'
Or, put this in a bash script to send you an email if traffic gets wild at night:
#!/bin/bash if sudo iftop -i eth0 -t | grep -q "100Mb/s"; then echo "Bandwidth exceeded!" | mail -s "Bandwidth Alert!" you@example.com fi
Note: For automation, vnstat
or bmon
might be better for long-term logging—but iftop
is awesome for “right now, what’s going on?” moments.
Fictionalized Admin Story
Meet Alex, a DevOps engineer who just moved their startup’s app to a shiny new VPS. One night, they get the dreaded “bandwidth cap warning” email. Panic! Alex SSHs in, launches iftop
, and instantly sees a single IP sucking up 70% of the upload traffic—turns out, a misconfigured backup job was syncing the entire database to an old dev server across the ocean. One kill
later, the traffic graph drops like a rock, and Alex sleeps soundly. Case solved.
Conclusion & Wrap-Up
iftop
is the unsung hero of server networking. It’s the fastest, geekiest, and most satisfying way to see “who’s eating your bandwidth” in real time—no setup, no agents, no vendor lock-in. If you run a VPS, dedicated server, or containerized cloud setup, drop iftop
into your toolkit now. You’ll wonder how you ever lived without it.
- Use it for emergencies, troubleshooting, or just to flex your terminal skills.
- If you need pretty graphs or historical stats, try
vnstat
ornload
alongside it. - For per-process tracking, check out nethogs.
Final geek pro-tip: Next time your network gets mysterious, don’t panic—just iftop
it!
Ready to put your bandwidth woes behind you? Get a rock-solid VPS or dedicated server and use iftop
to keep it running smooth.

This article incorporates information and material from various online sources. We acknowledge and appreciate the work of all original authors, publishers, and websites. While every effort has been made to appropriately credit the source material, any unintentional oversight or omission does not constitute a copyright infringement. All trademarks, logos, and images mentioned are the property of their respective owners. If you believe that any content used in this article infringes upon your copyright, please contact us immediately for review and prompt action.
This article is intended for informational and educational purposes only and does not infringe on the rights of the copyright owners. If any copyrighted material has been used without proper credit or in violation of copyright laws, it is unintentional and we will rectify it promptly upon notification. Please note that the republishing, redistribution, or reproduction of part or all of the contents in any form is prohibited without express written permission from the author and website owner. For permissions or further inquiries, please contact us.