Real-Time Network Monitoring with Iftop
Monitoring for Suspicious Activity
Security-conscious administrators can use iftop as part of their basic security monitoring toolkit. Iftop is not a replacement for dedicated security tools, but you can use it to help identify several types of suspicious activity, including:
- Unexpected external connections – Detect calls to unknown external IPs that might indicate malware or data exfiltration
- Port scanning activity – Identify multiple rapid connections to different ports on your host
- Data exfiltration attempts – Spot large outbound transfers to unexpected destinations
- DDoS participation – Notice many connections to a single external service
- Unauthorized services – Find unexpected listening ports receiving connections
Run iftop with appropriate filters to exclude known-good traffic, then look for connections to or from unexpected IP addresses or countries. Look for unusually high bandwidth to any single host, and watch for patterns that suggest scanning (many ports to one host). Investigate any suspicious findings with deeper tools.
Although iftop won't provide complete security visibility, it serves as an excellent "canary in the coal mine" to alert you to potential issues worth deeper investigation with tools like tcpdump, Wireshark, or a security information and event management (SIEM) system.
Verifying Network Configuration Changes
If you make a change to your network, iftop can provide immediate feedback to verify the result. This real-time validation is invaluable for ensuring changes have the intended effect without unexpected side effects. You can use iftop to confirm that the intended traffic is allowed or blocked following a change to firewall rules. Iftop also lets you verify bandwidth limits and prioritization for QoS implementations. If you make a change to a router, iftop will let you ensure that the traffic is flowing as intended.
For example, after implementing QoS to prioritize VoIP traffic, you could run iftop with the focus on common SIP/RTP ports:
iftop -f 'port 5060 or portrange 10000-20000'
Then initiate test calls while generating background traffic and verify that VoIP traffic maintains priority during congestion. This immediate feedback loop helps avoid situations where a configuration error becomes apparent at a critical moment.
Configuration File Options
Although iftop works well with default settings, power users can customize its behavior through a configuration file, typically located at ~/.iftoprc. This file allows persistent customization that applies across all iftop sessions without needing command-line options. See the iftop manpage for more on iftop configuration file settings.
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
-
Is AI Coming to Your Ubuntu Desktop?
According to the VP of Engineering at Canonical, AI could soon be added to the Ubuntu desktop distribution.
-
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.
