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

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.

ADVERTISEMENTS



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:



# iftop -i eth0

# iftop -f icmp

# iftop -F 192.168.1.0/24

# iftop -f 'not port domain'

See also:

Conclusion

In this example, I am using eth0 interface:Sample outputs: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:You can display or analyses packet flowing in and out of the 192.168.1.0/24 network:Disable output for DNS traffic by using filter code such as:iftop has many options read man page for further information see its man page – iftop(8)

And there you have it, you just learned how to display bandwidth usage on an interface by host. To get more info type the following man command or visit this page:

$ man iftop

$ iftop -h

iftop command options

Option Description -h display this message -n don’t do hostname lookups -N don’t convert port numbers to services -p run in promiscuous mode (show traffic between other hosts on the same network segment) -b don’t display a bar graph of traffic -B Display bandwidth in bytes -i interface listen on named interface -f filter code use filter code to select packets to count (default: none, but only IP packets are counted) -F net/mask show traffic flows in/out of IPv4 network -G net6/mask6 show traffic flows in/out of IPv6 network -l display and count link-local IPv6 traffic (default: off) -P show ports as well as hosts -m limit sets the upper limit for the bandwidth scale -c config file specifies an alternative configuration file -t use text interface without ncurses -o 2s Sort by first column (2s traffic average) -o 10s Sort by second column (10s traffic average) [default] -o 40s Sort by third column (40s traffic average) -o source Sort by source address -o destination Sort by destination address -s num print one single text output afer num seconds, then quit -L num number of lines to print