+4 votes
322 views
Monitor with real-time Linux network bandwidth iftop

in Linux / Unix by (552k points)
reopened | 322 views

1 Answer

+5 votes
Best answer

1. Install dependencies on Linux
2. Download and install iftop on Linux
3. Use iftop on Linux
4. Monitor the network interface in Linux

When working with Linux environments, it is ideal to have commands that help us manage tasks in a much more centralized way and that offer details of each of the aspects to be managed ..

Thinking about it we will talk about a useful command called iftop which will give us the opportunity to manage and keep strict control over the bandwidth of the current network and thus facilitate the task of control and determine when to take actions on this lineament.

Basically, the iftop command offers us a continuous and interactive view of the network traffic that passes through a network interface in the selected Linux distribution..

Through this tutorial we will see how to install iftop and thus manage the network bandwidth.


1. Install dependencies on Linux

Step 1

For iftop to work in the ideal way we must have the following dependencies:
libpcap
It is a library that allows you to capture live network data.
libncurses
It is a programming library that provides an API to build text-based interfaces in a terminal-independent manner.
Step 2

To install these dependencies we will execute the following. Enter the letter S to confirm the download and installation of the dependency packages.
 sudo apt install libpcap0.8 libpcap0.8-dev libncurses5 libncurses5-dev (Debian or Ubuntu) yum -y install libpcap libpcap-devel ncurses ncurses-devel (CentOS and RHEL) dnf -y install libpcap libpcap-devel ncurses ncurses-devel (Fedora 22 and higher) 
image

2. Download and install iftop on Linux

Step 1

Iftop is available in the official Debian and Ubuntu official software repositories so it can be installed using the apt command like this:
 sudo apt install iftop 
Step 2

In the case of CentOS and RedHat, it will be necessary to enable the EPEL repository and then proceed to its installation by executing the following:
 yum install epel-release yum install iftop 
Step 3

In the Fedora distribution, iftop is also available from the default system repositories, so we can use the following command:
 dnf install iftop 
Step 4

In the case of using other Linux distributions we can download Iftop using the wget command and executing some lines as follows:
 wget http://www.ex-parrot.com/pdw/iftop/download/iftop-0.17.tar.gz tar -zxvf iftop-0.17.tar.gz cd iftop-0.17 ./configure make make install 
image

3. Use iftop on Linux

Step 1

Once iftop is installed, we can go to the console and execute the iftop command without any argument to see the use of the default interface bandwidth like this: image
Step 2

In the case of having more open connections we will see the following. We can see detailed information of all packages that are being sent and received. image

4. Monitor the network interface in Linux

Step 1

For this we must know what is the interface to use and for this we can execute any of the following lines:
 sudo ifconfig sudo ip addr show 
Note
In case we do not have available ifconfig, we can install it by running the following:
 sudo apt install net-tools 
image image
Step 2

With these interfaces, we can use the -i parameter to specify the interface that we are going to monitor. For example, with the following command we will control the bandwidth in the Ethernet interface on the device:
 sudo iftop -i enp0s3 
image
Step 3

If we want to disable searches for host names, we can use the -n flag:
 sudo iftop -n eth0 
Step 4

To activate the display of the port used, we must add the -P parameter:
 sudo iftop -P 
image
Step 5

Some of the options we can use with iftop are:
sudo iftop -h
Display a message about the utility.
sudo iftop -N
It does not convert port numbers into services.
sudo iftop -p
It runs in promiscuous mode.
sudo iftop -b
It does not display the graphic bar on the network traffic.
sudo iftop -B
Displays bandwidth in bytes.
sudo -i interface
Run the selected interface.
sudo iftop -G net6 / mask6
It shows the flow of traffic in IPv6 addresses.
sudo iftop -F net / more
It shows the flow of traffic in IPv4 addresses.
sudo iftop -m limit
Set the upper limit for the bandwidth scale.
sudo iftop -t
Use the text interface without ncurses.
sudo iftop -o 2s
Sort by the first column
sudo iftop -o 10s
Sort by the second column.
sudo iftop -o 40s
Sort by the third column.
sudo iftop -o source
Sort by resource address.
sudo iftop -o destination
Sort by destination address.

In this way the iftop command is a great ally to manage in real time all the bandwidth in our network and be a support for the management tasks that are necessary to perform..


by (3.5m points)
edited

Related questions

+5 votes
1 answer
+3 votes
1 answer
asked Sep 26, 2019 in Linux / Unix by backtothefuture (552k points) | 931 views
+3 votes
1 answer
+3 votes
1 answer
+3 votes
1 answer
asked Oct 22, 2019 in Linux / Unix by backtothefuture (552k points) | 248 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users