Linux Display Bandwidth Usage on Network Interface By Host Using iftop command

Posted on in Categories Howto, Linux, Networking, RedHat/Fedora Linux last updated May 7, 2017

The iftop command listens to network traffic on a named network interface, or on the first interface, it can find which looks like an external interface if none is specified, and displays a table of current bandwidth usage by pairs of hosts. The iftop is a perfect tool for remote Linux server over an ssh based session.

iftop must be run by the root or the user who has sufficient permissions to monitor all network traffic on the network interface. See how to install iftop on CentOS/RHEL based server.

Installation

Type the command as per your Linux distro:

Install iftop on a Debian/Ubuntu Linux

Type the following apt-get command/apt command:
$ sudo apt-get install iftop

Install iftop on a CentOS/Fedora/RHEL/Scientific/Oracle Linux

Type the following yum command (first turn on EPEL repo):
$ sudo yum install iftop
Fedora Linux user type the following dnf command:
$ sudo dnf install iftop

Install iftop on Arch Linux

Type the following pacman command:
$ sudo pacman -S iftop

Install iftop on Alpine Linux

Type the following apk command:
# apk add iftop

Install iftop on Suse/OpenSuse Linux

Type the following zypper command:
# zypper install iftop

A note about installing iftop on Unix-like system

You can install iftop on Unix-like system such as FreeBSD, OpenBSD, MacOS and others too. This page only deals with Linux operating system. For example on FreeBSD one can install iftop using the following pkg command:
# pkg install iftop
On macOS Unix one can install it using the brew command:
$ brew install iftop

Examples

The syntax is:
iftop
iftop -i interface
iftop [options]

Type iftop command at the shell prompt to display traffic:
# iftop
Sample outputs:


In this example, I am using eth0 interface:
# iftop -i eth0
Sample outputs:
Animated gif 01: iftop command in action
Animated gif 01: iftop command in action

However, iftop works best when you use filters. For example, if you want to find out how much bandwidth users are wasting or trying to figure out why the network is slow, run:
# iftop -f icmp
You can display or analyses packet flowing in and out of the 192.168.1.0/24 network:
# iftop -F 192.168.1.0/24
Disable output for DNS traffic by using filter code such as:
# iftop -f 'not port domain'
iftop has many options read man page for further information see its man page – iftop(8)

See also:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

8 comment

  1. It is a very useful program. This commando shows I deal and the port of a single IP

    iftop -P -i any -F 62.165.165.245/32

  2. thanks, its great
    but i still have one question, can iftop change source ip (ex: 192.168.1.2 at picture above) to hostname from each pc that connected?

    regrads,..

  3. Something that works well via command line (especially for SSH) is iptraf. That lets you view stats with a wide variety of detail. Probably doesn’t work as well as this, but it works well enough πŸ˜‰

  4. Thanks iftop is really useful tool, but how you to make the opposite of this “iftop -F 192.168.1.0/24” i mean to exclude local bandwidth?

Comments are closed.