Skip to content

iftop Linux Command Guide

The iftop command in Linux is used to monitor network bandwidth usage in real-time. It displays a list of network connections and the amount of data flowing through them. With iftop, you can easily identify which hosts are using the most bandwidth, monitor specific interfaces, and view overall network activity. This command is particularly useful for system administrators and network engineers who need to troubleshoot network issues or optimize network performance.

Terminal window
iftop [options] [filter]
OptionDescription
-hDisplay help screen
-iSet the network interface to monitor
-BStart iftop in batch mode
-nDo not resolve hostnames. Display IP addresses instead
-NDo not resolve port numbers
-FDisplay data as flow rather than packets
-fFilter expression for packets to display
-BDisplay bandwidth in bytes
-bDisplay bandwidth in bits
-TDisplay TCP traffic only
-UDisplay UDP traffic only
-PDisplay only packets matching the filter expression
ParameterDescription
filterSpecify a filter expression for packets to display
Terminal window
iftop

Starts iftop to monitor incoming and outgoing network traffic.

Terminal window
iftop -i eth0

Starts iftop to monitor network traffic on a specific interface (in this case, “eth0”).

Terminal window
iftop -f "src host 192.168.1.1 or dst host 192.168.1.1"

Filters the iftop output to display traffic only to or from the specific host “192.168.1.1”.

Terminal window
iftop -F 192.168.1.0/24

Restricts the iftop output to monitor the traffic of hosts within the subnet “192.168.1.0/24”.

Terminal window
iftop -f "portrange 22-80"

Applies a display filter to show traffic only on ports 22 to 80.

Terminal window
iftop -t -s 1

Displays cumulative totals instead of a continuously updating graph, refreshing every 1 second.

Terminal window
iftop -6

Starts iftop to monitor IPv6 traffic in addition to IPv4 traffic.

To use the iftop command in Linux, execute the following command:

Terminal window
iftop

How can I specify a network interface with iftop?

Section titled “How can I specify a network interface with iftop?”

You can specify a network interface with iftop by using the -i flag followed by the interface name. For example:

Terminal window
iftop -i eth0

To display specific hosts with iftop, you can use the -f flag followed by a filter expression. For example, to display traffic only to or from a specific IP address, use:

Terminal window
iftop -f "src host 192.168.1.100 or dst host 192.168.1.100"

How to change the refresh interval in iftop?

Section titled “How to change the refresh interval in iftop?”

You can change the refresh interval in iftop by using the -t flag followed by the number of seconds. For example, to set the refresh interval to 5 seconds, use:

Terminal window
iftop -t 5

To display port numbers along with IP addresses in iftop, use the -P flag. For example:

Terminal window
iftop -P

You can resolve hostnames with iftop by using the -n flag. This will prevent iftop from performing DNS lookups. For example:

Terminal window
iftop -n
  • Monitor network bandwidth usage
  • Identify the source and destination of network traffic
  • View real-time data on network connections
  • Identify which applications are consuming the most bandwidth
  • Troubleshoot network congestion issues