TechEarl

iftop: See Bandwidth by Connection in Real Time

sudo iftop -i eth0 shows a live, per-connection bandwidth table: which host pairs are moving traffic and at what rate. The interface flag people forget, the -n and -P switches, the 2s/10s/40s columns, the filter syntax, and nload for total throughput per interface: -m, the graph scale, units, and the refresh interval.

Ishan KarunaratnePublished ⏱️ 15 min readUpdated
Share thisCopied
Use sudo iftop -i eth0 to watch bandwidth per connection live: -n, -P, the rate columns and BPF filters. Plus nload for total throughput per interface.

sudo iftop -i eth0 shows a live table of bandwidth grouped by connection: each pair of hosts talking to each other, with the send and receive rate for every pair. It answers "something is saturating this link, what is it?" This page covers iftop end to end, plus nload for the simpler question of how much total traffic an interface is moving.

The iftop command listens on one interface, ranks the busiest host pairs, and redraws the table a couple of times a second so you can watch the traffic move. Two things to know up front. First, iftop almost always needs root, because it puts the interface into promiscuous mode and reads packets directly (same as tcpdump), so run it with sudo. Second, it defaults to the first interface it finds, which is frequently the wrong one on a multi-NIC box, so get in the habit of passing -i explicitly. Everything else is making the output readable (-n, -N, -P), reading the three rate columns correctly, and scoping with a filter. If all you need is the aggregate in/out rate on a NIC, skip to nload for total interface bandwidth, which runs without root.

The one-liner

bash
sudo iftop -i eth0

That opens the full-screen display on eth0 and starts charting bandwidth per host pair. Press q to quit. If you omit -i, iftop picks the first non-loopback interface from the system list, which on a server with eth0, eth1, and a few veth/docker0 virtual interfaces is rarely the one you meant. Always name the interface. List your interfaces first with ip -br link if you are not sure what they are called.

Reading the display

The body of the screen is one row per host pair. The left column is the local end, the right column (after the => / <= arrows) is the remote end. The three numeric columns on the right are the moving averages of the transfer rate:

ColumnWindowWhat it tells you
1stlast 2 secondsthe instantaneous rate, jumpy
2ndlast 10 secondsthe useful "right now" number
3rdlast 40 secondsthe smoothed trend

The => row is traffic leaving the local host (transmit) and the <= row is traffic arriving (receive). At the very bottom, iftop prints cumulative totals: TX (sent), RX (received), and TOTAL, each with peak and cumulative figures for the run. Rates are shown in bits per second by default (Kb, Mb, Gb), not bytes, which trips up everyone the first time. A "100Mb" reading is 100 megabits, roughly 12.5 megabytes per second.

Make the output readable: -n, -N, -P

A default iftop run does reverse DNS on every address and hides ports, which is the opposite of what you usually want when you are chasing a problem. Three switches fix it.

bash
sudo iftop -i eth0 -n -P

-n turns off DNS resolution, so you see raw IP addresses instead of hostnames. This matters for two reasons: reverse lookups add latency and can stall the display, and on a busy host the constant DNS chatter from iftop itself shows up in the very table you are reading. -P turns on port display, appending :443, :22, :5432 and so on to each address so you can tell HTTPS from SSH from Postgres at a glance. -N is separate: it stops port numbers being resolved to service names, so a displayed port reads :443 rather than :https. It only affects how ports are labelled, so it is something you pair with -P (which is what turns port display on in the first place). Reach for -n -P when debugging; it is the most honest view.

Scope it with a filter

iftop accepts a Berkeley Packet Filter (BPF) expression after -f, the same syntax as tcpdump. This is how you stop watching everything and focus on one host, one port, or one protocol.

bash
sudo iftop -i eth0 -n -P -f "port 443"

That restricts the capture to traffic on port 443, so the table only shows HTTPS connections. A few more that earn their keep:

bash
sudo iftop -i eth0 -n -f "host 10.0.0.5"
sudo iftop -i eth0 -n -P -f "src port 22"
sudo iftop -i eth0 -n -f "net 192.168.1.0/24"

The first watches all traffic to or from a single host, the second isolates outbound SSH, the third scopes to one subnet. The filter is applied at capture time (it is a real BPF program, not a display filter), so it also reduces the load iftop puts on the box. You can edit the filter live without restarting: press f inside the running display and type a new expression.

For the common case of scoping to one network rather than building a BPF expression, iftop also takes -F net/mask for IPv4 (-G for IPv6), for example sudo iftop -i eth0 -n -F 192.168.1.0/24. This is a display-side filter on the source or destination network, narrower than -f but quicker to type when all you want is "just this subnet".

A worked example

Say a web server is pinned at its bandwidth cap and you want the culprit. Start broad on the public interface, IPs not names, ports on:

bash
sudo iftop -i eth0 -n -P

The table sorts by the 10-second average with the heaviest talkers at the top. Suppose the top row reads:

code
198.51.100.23:443        =>     12.4Mb   11.8Mb   9.30Mb
                         <=      820Kb    790Kb    410Kb

That single remote client is pulling roughly 12 megabits a second of outbound traffic on 443. Now confirm by scoping to it and watching the trend column settle:

bash
sudo iftop -i eth0 -n -P -f "host 198.51.100.23"

If the 40-second column holds steady near 12Mb, that one connection is your sustained load, not a momentary spike. From here it is a firewall rule or a rate-limit, but iftop has already told you the where and the how-much in under a minute.

Useful interactive keys

Once iftop is running, single keypresses reshape the view without a restart:

  • p toggles port display on and off (same as launching with -P).
  • n toggles DNS resolution (same as -n, but inverted: it enables/disables lookups live).
  • P (capital) pauses the display so you can read a frozen frame.
  • t cycles the line-display mode: two lines per pair (send + receive), one combined line, send only, receive only.
  • < and > change the sort column (by source, destination, or one of the rate averages).
  • 1, 2, 3 sort directly by the 2-second, 10-second, or 40-second average respectively, a faster way to reorder the table than cycling with </>.
  • j / k scroll the list when there are more pairs than fit on screen.
  • f edits the filter code live.
  • h shows the help screen with the full key list; q quits.

These are worth learning because the common workflow is "launch broad, then narrow interactively" rather than relaunching with new flags each time.

Caveats and distro differences

iftop is not always installed. On Debian and Ubuntu it is sudo apt install iftop; on RHEL, Rocky, and AlmaLinux it is in EPEL (sudo dnf install epel-release && sudo dnf install iftop); on Alpine it is apk add iftop. It depends on libpcap, which is why the filter syntax matches tcpdump.

A few honest limits:

  • iftop shows rates, not processes. It tells you which hosts and ports are busy, never which PID owns the socket. To map a connection back to a process, pair it with ss -tanp or lsof -i, or reach for nethogs, which groups bandwidth by process instead of by connection. This is the network analogue of using iotop to find the process hammering your disk: same live-monitor pattern, different resource.
  • It needs root, or CAP_NET_RAW. Running as an unprivileged user without that capability fails with a permission error on the pcap open. sudo is the normal answer; granting the capability with setcap cap_net_raw+ep $(which iftop) is the alternative if you genuinely cannot use sudo.
  • The bits-vs-bytes default catches people. If you think in megabytes, either divide the reading by 8 or launch with -B to show rates in bytes per second instead. Pressing B toggles the same thing live.
  • On very high-throughput links it can drop frames. iftop is a monitoring tool, not an accounting tool; for billing-grade totals use the kernel's own counters (/proc/net/dev, vnstat) rather than iftop's cumulative figures.

Watch total interface bandwidth with nload

nload answers the coarser question iftop is overkill for: is this box saturating its link right now? It draws a live, scrolling graph of incoming and outgoing bandwidth on one interface, with the current rate plus the average, min, max, and total transferred. It is a traffic-rate monitor, not a per-connection or per-process one: it tells you the interface is moving 400 Mbit/s, not which host is responsible. That narrow job is exactly why it is so quick to read, and why I usually run it before iftop.

It also differs from iftop on privileges. On Linux nload reads the interface counters out of /proc/net/dev, which is world-readable, so an ordinary user runs it without sudo. Only the install needs root. There is no daemon and nothing to configure.

Install and run nload

bash
# Debian / Ubuntu
sudo apt install nload

# Fedora / RHEL / Rocky (EPEL on RHEL family)
sudo dnf install nload

# Arch
sudo pacman -S nload

# macOS (Homebrew)
brew install nload

The package is the same upstream project everywhere: Roland Riegel's nload. Then, as your normal user:

bash
nload

With no arguments it opens on the first non-loopback interface. The top half is incoming traffic, the bottom half outgoing, each with a scrolling bar graph and a stats block to the right:

code
Device eth0 [192.0.2.10] (1/2):
======================================
Incoming:
                                         Curr: 412.18 MBit/s
   .|||                                  Avg: 388.04 MBit/s
  .||||.   .|                            Min: 0.00 Bit/s
.|||||||| .|||.                          Max: 451.77 MBit/s
||||||||||||||||                         Ttl: 18.42 GByte
--------------------------------------
Outgoing:
                                         Curr: 6.91 MBit/s
                                         Avg: 5.88 MBit/s
   .|                                    Min: 0.00 Bit/s
.|.||.  .|                               Max: 12.04 MBit/s
||||||||||||                             Ttl: 1.07 GByte

Curr is the rate right now, Avg is the running average over the averaging window, Min and Max are the lowest and highest rates seen, and Ttl is the cumulative bytes transferred while nload has been running. The (1/2) in the header means interface 1 of 2. Press q or Ctrl+C to quit; F2 opens the options screen, F5 saves the current settings, and F6 reloads them.

Switch interfaces, or show them all with -m

Cycle interfaces live with the left and right arrow keys, or name one so nload starts on it directly. Pass several and the arrows page through just those:

bash
nload eth0
nload eth0 wg0 docker0

To see every interface at once instead of one per screen:

bash
nload -m

-m switches to multiple-device mode: each interface gets a compact two-line In/Out summary stacked on one screen, no scrolling graph. This is the view I actually use on a busy host, because the question is usually "which interface is hot", and a wall of small In/Out readouts answers that faster than paging through full graphs.

Fix the graph scale and the units

The graph's 100% mark defaults to a fixed 10240 kBit/s (10 Mbit/s), so on a gigabit link the bars peg to the top constantly and tell you nothing. Set the mark to your link's real rate so the height means something:

bash
nload -i 102400 -o 102400 eth0

-i sets the top of the incoming graph and -o the outgoing, both in kBit/s. 102400 kBit/s is 100 Mbit/s, so a full-height bar now means a saturated 100 Mbit link. Passing -i 0 switches that graph to auto-scaling instead: handy on a link whose ceiling you do not know, distracting on one you do.

bash
nload -u M -U G eth0

-u sets the unit for the traffic rates (Curr/Avg/Max) and -U the unit for the totals (Ttl). The letters are b k m g for bits and B K M G for bytes, plus h (or H) for human-readable auto-scaling. The defaults are -u k and -U M, so -u M -U G forces rates into MBit/s and totals into GByte, which keeps the numbers steady instead of flipping units as traffic changes.

-t sets the refresh interval in milliseconds (default 500): nload -t 200 eth0 gives a twitchier graph that reacts faster to bursts, 2000 a calmer readout on a noisy link. It only affects the display refresh, not how often the kernel counters update. -a sets how many seconds of history the Avg line covers; the default is 300, so Avg is a five-minute mean. Shorten it if a long average is hiding short spikes you care about.

FlagMeaningDefault
-mMultiple-device view (compact In/Out per interface, no graph)off (single device, graphed)
-t MSRefresh interval in milliseconds500
-i KBITS100% mark for the incoming graph in kBit/s (0 = auto-scale)10240
-o KBITS100% mark for the outgoing graph in kBit/s (0 = auto-scale)10240
-u UNITUnit for traffic rates (b k m g bits, B K M G bytes, h/H auto)k
-U UNITUnit for totals (same letters as -u)M
-a SECONDSLength of the averaging window for the Avg figure300
devices...Restrict to named interfaces (e.g. eth0 wg0)all real interfaces

Say a backup over the network feels slow and I want to know whether the link is the bottleneck or something upstream is throttling. I pin the scale to the link's rated speed and force MBit/s so the reading does not jump around:

bash
nload -u M -i 1024000 -o 1024000 eth0

1024000 kBit/s is roughly 1 Gbit/s, so the incoming graph fills the height only when the link is genuinely maxed. If Curr parks at ~940 MBit/s and the bar is pinned to the top, the wire is the limit and there is nothing to tune on this box. If it sits at 300 MBit/s with the bar a third of the way up while the transfer crawls, the bottleneck is elsewhere (disk, the sender, a shaper in the path). When the wire is saturated, switch to sudo iftop -i eth0 -n -P to see which conversation is filling it. When it is not, the disk is the next suspect, and iotop shows which process is hammering it.

nload stores nothing: it only shows the live window. For graphs over days and threshold alerts you want a real collector (Prometheus with node_exporter, vnstat for long-term totals, or your monitoring stack).

iftop vs nload vs the others

These tools answer different questions. Pick by what you are actually trying to learn.

ToolGranularityBest for
iftopper connection (host pair + port)"which conversation is using the bandwidth?"
nloadper interface, total in/out"how saturated is this NIC right now?"
nethogsper process"which program is using the bandwidth?"
iftop -ffiltered subset"how much traffic does this one host/port move?"

Reach for iftop when the question is who is talking to whom and how loud. If you only need the aggregate throughput on an interface, nload is the lighter tool, needs no root, and does not need a filter expression to be useful. If you need to attribute traffic to a process rather than a remote host, nethogs is the one. And if you are mapping out what is actually listening or reachable rather than what is transferring, that is a scan job, not a monitor job: see the nmap command examples for the surface-area side of the same investigation.

See also

FAQ

iftop is a command-line tool that shows bandwidth usage on an interface broken down by connection, in real time. It lists each pair of hosts exchanging traffic and the send and receive rate for each pair, redrawing a couple of times a second. It answers "what is using my bandwidth right now" at the level of host pairs and ports, unlike per-interface monitors such as nload that only show the total. Run it with sudo iftop -i eth0.

iftop reads raw packets off the interface and puts it in promiscuous mode, the same as tcpdump, which requires the CAP_NET_RAW capability. An unprivileged user does not have it, so the capture fails with a permission error. The usual fix is sudo; if you cannot use sudo, you can grant the capability to the binary with setcap cap_net_raw+ep $(which iftop). nload only reads the interface counters in /proc/net/dev, which is world-readable, so an ordinary user can run it without sudo. Only installing it needs root.

They are the transfer rate averaged over three windows: the last 2 seconds, the last 10 seconds, and the last 40 seconds. The 2-second figure is jumpy and shows momentary spikes; the 10-second figure is the practical "right now" number; the 40-second figure smooths out into a trend so you can tell a sustained transfer from a brief burst. All three are in bits per second by default, not bytes, so divide by 8 to get megabytes, or launch with -B to read them in bytes directly.

Add -n to disable DNS resolution (raw IPs instead of hostnames) and -P to show port numbers: sudo iftop -i eth0 -n -P. Turning off DNS also stops iftop's own reverse lookups from appearing in the table and removes the lookup latency that can stall the display. You can also toggle both live: press n to switch DNS resolution and p to switch port display while iftop is running.

Yes. Pass a Berkeley Packet Filter expression after -f, using the same syntax as tcpdump: sudo iftop -i eth0 -n -f "host 10.0.0.5" watches one host, -f "port 443" watches HTTPS only, -f "net 192.168.1.0/24" scopes to a subnet. The filter runs at capture time, so it also lowers the load iftop puts on the box. You can edit it live by pressing f inside the running display.

No. iftop groups traffic by host pair and port, never by PID, and nload only reports the aggregate rate on the interface. To attribute bandwidth to a process, use nethogs, which groups traffic by PID, or correlate iftop's host/port against ss -tanp or lsof -i to find the matching socket. The same split exists for disk IO: iftop is to network what iotop is to disk, except iotop does report the process.

They monitor at different granularities. nload shows the total incoming and outgoing throughput for a whole interface as two scrolling graphs, which answers "how saturated is this NIC". iftop breaks the same traffic down by connection, showing each host pair and its rate, which answers "which conversation is using the bandwidth". Use nload for a quick saturation check and iftop when you need to find the specific talker.

Press the left and right arrow keys to cycle through the interfaces; the header shows your position, like (1/2). To start on a specific one, name it on the command line: nload eth0. You can list several (nload eth0 wg0) to page through just those, or run nload -m to see a compact In/Out summary for every interface on a single screen.

By default rates show in kBit/s (-u k) and totals in MByte (-U M). The -u flag changes the unit for the rate lines and -U for the totals. The letters are b k m g for bits and B K M G for bytes, plus h (or H) for human-readable auto-scaling. nload -u M -U G eth0 forces rates into MBit/s and totals into GByte so the numbers stay steady.

By default the 100% mark sits at 10240 kBit/s (10 Mbit/s), so on a faster link the bars peg to the top and stop being informative. Set the mark to your link's real rate in kBit/s with -i for incoming and -o for outgoing: nload -i 1024000 -o 1024000 eth0 puts the top of the graph at roughly 1 Gbit/s. Pass -i 0 to auto-scale instead when you do not know the ceiling.

Sources

Authoritative references this article was fact-checked against.

TagsiftopnloadBandwidth MonitoringNetworkLinuxCLISystem Administrationtcpdump

Found this useful? Pass it on.

Copied

Ishan Karunaratne

Systems and Network Architect · Chief Technology Officer

Systems and network architect and Chief Technology Officer with more than two decades designing, building, and running production software, cloud and network architecture, Linux systems, and the bare metal underneath them, and lately working AI into the stack. A US Army veteran who served in Operation Iraqi Freedom. What I write here is drawn from the full arc of that work, across architecture, engineering, and operations, not any single job.

Keep reading

Related posts

Using regex in Nginx with location blocks and the rewrite directive: location modifier priority, the rewrite directive flags, return-based redirects, and copy-paste config for HTTPS redirects, www normalization, trailing slashes, 301 redirects, clean URLs, and blocking by user-agent or IP.

How to Use Regex in Nginx (location and rewrite)

Use regex in Nginx with location blocks and the rewrite directive: how location modifiers and matching priority work, why return beats rewrite for redirects, and copy-paste config for HTTPS, www, trailing slashes, 301s, clean URLs, and access blocking.

Fix the WordPress "Error establishing a database connection": bad wp-config credentials, MySQL or MariaDB down, connection limits, or a cached error page.

How to Fix "Error Establishing a Database Connection" in WordPress

Error establishing a database connection means WordPress cannot reach its database. Read the MySQL error code to find the real cause (wrong credentials, a stopped server, a connection limit, corrupted tables, or a cloud firewall), and if the error outlives the fix, stop the cache from serving it. Also covers the stuck "Briefly unavailable for scheduled maintenance" page.