Real-Time Network Monitoring with Iftop
Interactive Controls
Iftop becomes particularly powerful when you use its interactive controls to customize the display in real-time. These keyboard commands allow you to adapt the view to your immediate troubleshooting needs without restarting the tool. Type a keyboard key and watch the display react. You can toggle the port number display (p), display or hide the source address (s) or destination address (d), or display total bandwidth (t). Type n to toggle hostname resolution, which is helpful for reducing DNS lookups. Type P to freeze the current view and pause the display. Enter a 1, 2, or 3 to sort columns 1, 2, or 3 of the bandwidth timescales. The l option lets you enter a BPF filter expression.
Iftop's controls allow you to quickly focus on the most relevant connections for your current troubleshooting needs. For example, when diagnosing a bandwidth saturation issue, you might start with the default view to identify the heaviest flows, then press S to group by source if a particular host seems responsible. From there, press p to show the ports in order to identify the services responsible. Enter j/k to scroll through all connections from the host.
Filtering Traffic with BPF Expressions
One of iftop's most powerful features is its ability to filter traffic using Berkeley Packet Filter (BPF) expressions. This packet filtering language allows you to focus on specific types of traffic while excluding irrelevant data from the display. BPF filters can be applied either at startup via command line or interactively while iftop is running.
Common Filtering Scenarios
Common filtering scenarios include view-only HTTP traffic (port 80):
sudo iftop -f 'port 80'
monitor traffic to/from a specific host:
sudo iftop -f 'host 192.168.1.100'
exclude SSH traffic (port 22) from display:
sudo iftop -f 'not port 22'
monitor traffic between specific subnets:
sudo iftop -f 'net 192.168.1.0/24 and net 10.0.0.0/8'
and view-only UDP traffic (useful for VoIP or streaming analysis):
sudo iftop -f 'udp'
You can also apply these filters interactively by pressing l and entering the filter expression. This allows you to quickly change what you're monitoring based on what you see in the initial display. For example, you might start with a broad view to identify interesting traffic. If you notice heavy traffic on port 443, press l and enter port 443 to focus just on HTTPS traffic. Then press S to sort by source to see which hosts are generating this traffic.
The ability to dynamically apply these filters makes iftop exceptionally flexible for drilling down into network issues.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Framework Laptop 13 Pro Competes with the Best
Framework has released what might be considered the MacBook of Linux devices.
-
The Latest CachyOS Features Supercharged Kernel
The latest release of CachyOS brings with it an enhanced version of the latest Linux kernel.
-
Kernel 7.0 Is a Bit More Rusty
Linux kernel 7.0 has been released for general availability, with Rust finally getting its due.
-
France Says "Au Revoir" to Microsoft
In a move that should surprise no one, France announced plans to reduce its reliance on US technology, and Microsoft Windows is the first to get the boot.
-
CIQ Releases Compatibility Catalog for Rocky Linux
The company behind Rocky Linux is making an open catalog available to developers, hobbyists, and other contributors, so they can verify and publish compatibility with the CIQ lineup.
-
KDE Gets Some Resuscitation
KDE is bringing back two themes that vanished a few years ago, putting a bit more air under its wings.
-
Ubuntu 26.04 Beta Arrives with Some Surprises
Ubuntu 26.04 is almost here, but the beta version has been released, and it might surprise some people.
-
Ubuntu MATE Dev Leaving After 12 years
Martin Wimpress, the maintainer of Ubuntu MATE, is now searching for his successor. Are you the next in line?
-
Kali Linux Waxes Nostalgic with BackTrack Mode
For those who've used Kali Linux since its inception, the changes with the new release are sure to put a smile on your face.
-
Gnome 50 Smooths Out NVIDIA GPU Issues
Gamers rejoice, your favorite pastime just got better with Gnome 50 and NVIDIA GPUs.
