Iftop, monitor the bandwidth consumption of your network in real time

About iftop

In the next article we are going to take a look at iftop. Some time ago we talked in this blog about how to kill processes, and in that post we reviewed the use of Top. For this article we are going to try another excellent program called Interface TOP (IFTOP), which is a bandwidth monitoring tool console-based that works in real time.

Iftop has been doing for network usage what top does for CPU usage. The program in question listens to network traffic on an interface and displays a table of current bandwidth usage by host pairs. The program will display a quick overview of network activities on its interface. Iftop displays a real-time updated list of bandwidth usage every 2, 10 and 40 seconds on average. In this post we are going to see the installation and how to use IFTOP with basic examples in Ubuntu.

This software you are going to need some dependencies that we will have to install before getting involved with the installation of the program. These requirements are:

  • libpcap: It is a library for capturing live network data. It can be used by a program to capture packets that travel throughout the network.
  • libncurses: This is a programming library. Provides an API for building text-based interfaces in a terminal independent way.

Install dependencies

Like i said, first we will install libpcap and libncurses libraries using our package manager according to the Gnu / Linux distribution that we use. In Ubuntu we will only have to open a terminal (Ctrl + Alt + T) and write:

sudo apt install libpcap0.8 libpcap0.8-dev libncurses5 libncurses5-dev

Install iftop

Iftop is available from the official Debian / Ubuntu software repositories. We can install it using the apt command in the terminal (Ctrl + Alt + T) as shown below:

sudo apt install iftop

Basic use of Iftop

Once the installation is finished, we will only have to open a console and run the iftop command without any arguments to view the bandwidth usage of the default interface. The program will show us a screen similar to the one shown below:

iftop enp0s3

sudo iftop

It is necessary to indicate that it is necessary to be able to execute the tool to have root permissions.

If we want to see more options of the tool during its execution, we will only have press the "h" key. We will be shown a help menu with various options.

iftop -h

While iftop is running, we can use the keys like S, N and D to see more information such as source, destination, etc. Run man iftop if you want to explore more options. Press 'q' to exit of program execution.

Monitor a network interface

iftop -P

We will first execute the ifconfig command or ip command for find all network interfaces connected to our system:

sudo ifconfig

Or we can also use:

sudo ip addr show

Knowing the interfaces, we can now use the -i option to specify the interface we want to monitor. For example, with the following command, in my case, I will be able to control the bandwidth of the enp0s3 interface on the computer from which I am testing this program:

sudo iftop -i enp0s3

If what we want is determine the packets going to / from an ip such as 10.0.2.15/24, we will use the -F option. In this way we can more easily detect the cause of a bottleneck.

sudo iftop -F 10.0.2.15/255.255.255.0 -i enp0s3

Now, if what we want is validate if they are ICMP or TCP / IP packets the causes of the turtle effect of our network. we can use the -f option:

iftop -f icmp -i enp0s3

Uninstall itop

We will be able to remove this program from our computer by opening a terminal (Ctrl + Alt + T) and typing in it:

sudo apt remove iftop

This article only shows how to install and use iftop in a basic way, to monitor our network in Gnu/Linux. If someone wants to know more about iftop, in addition to the help of the program, they can visit the project website or consult your source code.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.