Home Linux ServerTools iftop – A detailed network bandwidth monitoring tool on Linux

iftop – A detailed network bandwidth monitoring tool on Linux

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

In this article, AZDIGI will show you how to install iftop and use it.

I. Introduction

In my previous article, AZDIGI introduced nload as a tool for monitoring bandwidth usage, but it’s relatively simple and doesn’t go into much detail. In this article, AZDIGI will introduce another excellent program called Interface TOP (IFTOP) which is a detailed real-time network bandwidth monitoring tool on Linux.

It will display quick information about network activities on an interface. Iftop will display a list of network bandwidth-consuming processes updated in real-time averaging every 2, 10, and 40 seconds. In this guide, I will guide you on how to install and use IFTOP with some examples on Linux.

II. Install iftop on the Linux server

Before going through the installation steps, we need to install the required dependencies for iftop. 2 libraries that need to be installed are:

  • libpcap: Library for directly collecting network data.
  • libncurses: The programming library that provides API for building text-based interfaces.

Step 1: Install libpcap and libncurses

First, let’s start by installing the libpcap and libncurses libraries with the following commands:

AZDIGI Tutorial
-------- Trên máy chủ Debian/Ubuntu --------
sudo apt install libpcap0.8 libpcap0.8-dev libncurses5 libncurses5-dev

-------- Trên máy chủ CentOS 7/RHEL --------
yum  -y install libpcap libpcap-devel ncurses ncurses-devel

-------- Trên máy chủ Fedora 22+ --------
dnf  -y install libpcap libpcap-devel ncurses ncurses-devel
    

Step 2: Install iftop

This software is available in the official software repository of Debian/Ubuntu Linux, so you can install it with the apt command as follows:

AZDIGI Tutorial
sudo apt install iftop
    

In RHEL/CentOS 6&7, you need to enable the EPEL repository, then install it with the following two commands:

AZDIGI Tutorial
yum install epel-release -y
yum install  iftop -y
    

CentOS 8 and Fedora are also available on the repositories so you just need to use the following command:

AZDIGI Tutorial
dnf install  iftop -y
    

Below I’m using a CentOS 8 VPS to install.

iftop-linux-network-bandwidth-monitoring-tool

In case you are using other Linux versions, you can download the source code of iftop and recompile it for use with the following commands:

AZDIGI Tutorial
wget http://www.ex-parrot.com/pdw/iftop/download/iftop-1.0pre4.tar.gz
tar -zxvf iftop-1.0pre4.tar.gz
cd iftop-0.17
./configure
make
make install
    

You can replace the download link with the higher version at this link.

III. Guide to using iftop

Basic use

Once it’s installed, go to your control panel and run the iftop command to see the bandwidth usage of the default theme, below is the interface of use:

iftop-linux-network-bandwidth-monitoring-tool

At this interface, you can see which IP is connecting to your server and how much bandwidth your server is using, whether it’s high or low.

Use to monitor a certain network card

First, you need to determine how many network cards your server has and what each network card name is with one of the following two commands:

AZDIGI Tutorial
sudo ifconfig
Hoặc
sudo ip addr show
    
iftop-linux-network-bandwidth-monitoring-tool

Then you just need to add the -i option and the name of the network card you want to track. For example, if I want to track my eth0 card, I will use the following command:

AZDIGI Tutorial
sudo iftop -i eth0
    
iftop-linux-network-bandwidth-monitoring-tool

To disable hostname lookup, add the -n option in your command line.

AZDIGI Tutorial
sudo iftop -n -i eth0
Hoặc
sudo iftop -ni eth0
    
iftop-linux-network-bandwidth-monitoring-tool

To enable more information about the port in use, please use the -P option.

AZDIGI Tutorial
sudo iftop -P -n -i eth0
Hoặc
sudo iftop -Pni eth0
    
iftop-linux-network-bandwidth-monitoring-tool

Some more options

While using iftop, you can use keys like S, D to view more information like source, destination, etc. Run iftop -h f you want to explore more options and tricks. Press q to exit running windows.

AZDIGI Tutorial
iftop -h
    
iftop-linux-network-bandwidth-monitoring-tool
See all options using iftop.

IV. Summary

Hopefully, through this article, you will learn about another useful tool to better manage your server. If you are still interested in monitoring software, you can check out the following articles:

If you need assistance, you can contact support in the ways below:

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign