Linux iftop – Listen Network Traffic and Bandwidth
The iftop listens to network traffic on a specified network interface. The iftop is a perfect tool for remote Linux server over a ssh based session.iftop displays the bandwidth usage by a pair of hosts in the form of a table. To run this tool we must have superuser (root)permissions.
Installation iftop on Debian based system like Ubuntu, Kali Linux:
To install the iftop tool on Debian based system run the following command in terminal
sudo apt-get install iftop
Installation iftop on Arch Linux:
To install iftop on Arch-based system run the following command in terminal
sudo pacman -S iftop
Install iftop on a CentOS/Fedora/RHEL/ Linux:
To install the iftop on OS like CentOS we can use the yum package manager. Run the following command :
sudo yum install iftop
Now let’s use the iftop. As we know we must provide the superuser permission to run this tool there for always use sudo while running this tool. Use the following command to run the iftop.
sudo iftop -i INTERFACE
In the above command replace the INTERFACE with your network interface. The Default network interface used specified in iftop is eth0. But to know your current interface run the following command
Then you will get your interface. In my case, I am using Wi-Fi therefore my network interface is wlo1 therefore for I used the following command.
Then the output will be like:
Let’s discuss output.In above output we can see there are two arrows are used ( ==> ) and ( <<) . See one by one is mean by that arrows.
1) ==>: This arrow indicates that the data is sent from x host to y host like. We can also call is uploading data.
x ==> y
This arrow means the data is received from y host to x host like. We can call this process downloading data.
x << y
Then there is some bar which is the logarithmic scale for the bar graph which gives a visual indication of traffic. Then there are three columns are shown with the same data. This column shows the data usage in intervals of 2s, 5 s, and 40s. Then below the horizontal line, we can see the Tx(Transmit) and RX(Receive) data usage. And Total data used by the interface.
Options of iftop:
The iftop provide some option to use it more efficiently .let’s see it one by one
-h option: This option is used as help. On running the iftop with the -h option it will show all option and information about the iftop.
sudo iftop -h
-i option: This option is used to specify the network interface like wlan0 or eth0.
sudo iftop -i wlan0
-m option: This option is used to set a limit to bandwidth to output in use the -m option like the following command.
sudo iftop -i INTERFACE -m LIMIT
Here in the place of INTERFACE use your network interface and in place of LIMIT type the output limit in Bits. For example, I have used the following command
sudo iftop -i wlo1 -m 100
I have set the limit of 100 bits .In output, we can see the maximum limit is 100bits.
-F option: This option is used to analyze the traffic on a specific IPv4 network. If this is specified then iftop will only include the packets flowing in to out of the given network.
sudo iftop -i INTERFACE -F net/mask
sudo iftop -i wlo1 -F 24
And there are many other options you can see and use by -h option with iftop.