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

Download Article PDF now with Express Checkout
Price $2.95
(incl. VAT)

Buy Linux Magazine

Related content

  • Top Ten Tops

    The famous Unix admin utility known as Top has many imitators. We take a look at some of the top Top tools.

  • Charly's Column

    Network monitors are a dime a dozen, but Nload, which separates incoming and outgoing traffic and draws graphs on the console without X, is unique.

  • Linux News

    News

    • US gov embraces open data
    • Apache Cdorked.A exploit discovered
    • News Bites

    New Intel CEO

    • FSF scolds W3C
    • Torvalds releases Kernel 3.9
    • Xen new LF collaboration project

    Operating Systems

    • Debian 7.0“wheezy” debuts
    • Windows XP most likely to be victim of attack.
  • Bpytop

    Linux users have many options for monitoring system resources, but bpytop, a new Python port of bashtop, more than stands out from the crowd.

  • The sys admin’s daily grind: Sysdig

    In this issue, sys admin columnist and tool veterinarian Charly Kühnast invites Sysdig, the jack-of-all-trades among system diagnostic tools, into his surgery for a quick checkup. The project promises to unite the functionality of lsof, iftop, netstat, tcpdump, and others.

comments powered by Disqus
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.

Learn More

News