Use iftop To Monitor Network Bandwidth Usage

Updated on January 24, 2016
Use iftop To Monitor Network Bandwidth Usage header image

iftop is a network bandwidth monitoring utility that can be used to diagnose network performance degradation in real time.

In this tutorial, we will be covering the the installation and basic usage of iftop on CentOS 6. This article can be used as a reference for other RPM-based Linux distributions.

Prerequisites

  • A CentOS 6x x64 bit instance.
  • A sudo user.

Installing iftop using Yum

iftop is not available in the base CentOS yum repository, it is however available in the epel repository. Therefore, we will need to install epel in order to install iftop:

sudo yum install epel-release
sudo yum update
sudo yum install iftop

Run iftop

sudo iftop

Without additional parameters, iftop will monitor all the inbound and outbound traffic on the default network interface. e.g. eth0.

To monitor a different network interface, e.g. eth1, you would need to pass the interface name to the iftop command using the -i parameter:

sudo iftop -i eth1

Inside the iftop program:

On the top of the screen is a scale which is used to indicate the bandwidth usage of each network connection listed below.

The information on the top of the screen indicates the bandwidth each network connection is consuming.

In the center, a list of all network connections on the monitored interface is displayed. The arrow at the end of each line indicates whether the traffic is inbound or outbound.

The last three columns show the average bandwidth usage for each connection during the last 2, 10, and 40 seconds.

The section at the bottom of the screen displays the overall traffic statistics including transmitted traffic Tx, received traffic Rx, and the grand total TOTAL. iftop provides the cumulative bandwidth usage (cum) for each type of traffic, the peak bandwidth usage (peak), and the average bandwidth usage during the last 2, 10, and 40 seconds.

iftop's interface is rather customizable. Using a set of predefined keys, you can alter the way in which data is displayed:

  • h: Toggle between displaying and not displaying help.
  • j: Move down.
  • k: Move up.
  • n: Toggle between disabling and not disabling hostname resolution. Disabling hostname resolution can accelerate the program.
  • N: Toggle between displaying port number and displaying service name.
  • s: Toggle between displaying and not displaying local host.
  • S: Toggle between displaying and not displaying ports of local host.
  • d: Toggle between displaying and not displaying destination host.
  • D: Toggle between displaying and not displaying ports of destination host.
  • p: Toggle between displaying and not displaying ports.
  • P: Toggle between pausing display and resuming display.
  • t: Toggle among "two lines per host", "one line per host", "received traffic only", and "sent traffic only".
  • <: Sort by the source host.
  • : Sort by the destination host.

  • q: Quit the program.

This concludes our tutorial. For more information on how to use iftop, please refer to iftop's website.

Thank you for reading.