Log inSign up

Find out what is using your bandwidth with iftop and nethogs

Install iftop and nethogs (from EPEL on Rocky and Alma), then run sudo iftop -i eth0 -nNP to rank remote hosts by current traffic and sudo nethogs eth0 to rank local programs. Both show live rates only; for monthly totals against your plan transfer, use the vnstat setup in the usage monitoring tutorial.

Topic: Networking and diagnostics · Tested on: Ubuntu 24.04 and 22.04, Debian 12 and 13, Rocky Linux 9, AlmaLinux 9 · Updated 2026-12-03

What is the difference between iftop and nethogs?

iftop groups traffic by connection pair (your server and one remote host), while nethogs groups it by local process. Use iftop to answer "who is my server talking to so heavily" and nethogs to answer "which program on my server is responsible". Both read packets through libpcap and show rates over the last few seconds, so they suit live troubleshooting: a sudden spike, a slow download, a backup job that saturates the link.

Neither tool keeps history. Your plan has a monthly outgoing transfer allowance, and the right tool for tracking it is a counter that survives reboots, which the usage monitoring tutorial sets up with vnstat. The Usage graphs tab on the instance page in the console also shows recent traffic for the server.

How do you install both tools?

On Ubuntu and Debian both are in the main archive:

sudo apt update
sudo apt install -y iftop nethogs

On Rocky Linux 9 and AlmaLinux 9 they come from EPEL, the extra packages repository maintained by the Fedora project:

sudo dnf install -y epel-release
sudo dnf install -y iftop nethogs

Check what you received. nethogs has a version flag, and the package manager reports the iftop release:

nethogs -V
apt policy iftop        # Ubuntu and Debian
rpm -q iftop nethogs    # Rocky and Alma
ip route show default

The last command tells you the public interface name after dev. The examples below use eth0.

How do you read the iftop screen?

Start iftop with address and port names turned off, because reverse lookups are slow and generate their own traffic:

sudo iftop -i eth0 -nNP

-n keeps addresses numeric, -N keeps port numbers instead of service names, and -P shows ports so you can tell SSH from HTTPS. Each pair takes two lines: => is traffic leaving your server and <= is traffic arriving. The three columns on the right are average rates over the last 2, 10 and 40 seconds. The footer shows TX, RX and TOTAL with cumulative bytes since start, the peak rate, and the same three averages.

Add -B to display bytes per second instead of bits per second when you compare with file sizes. The scale at the top adapts to the busiest flow; press L to switch between a linear and a logarithmic scale.

Which iftop keys and filters are useful?

iftop takes keystrokes while it runs:

  • 1, 2, 3 sort by the 2, 10 or 40 second column.
  • s and d hide the source or destination host so traffic is summed per remote host or per local address.
  • t cycles between two line, one line, sent only and received only.
  • T adds a cumulative total per row, o freezes the current order.
  • l sets a screen filter, f edits the packet filter live, q quits.

Packet filters use the same syntax as tcpdump. Hiding your own SSH session keeps the view honest:

sudo iftop -i eth0 -nNP -f 'not port 22'
sudo iftop -i eth0 -nNP -f 'port 443'
sudo iftop -i eth0 -nNP -f ip6

For scripts or a quick snapshot without the full screen interface, text mode prints one report and exits:

sudo iftop -i eth0 -nNP -t -s 10 -L 10

That listens for ten seconds and prints the ten busiest flows, which you can paste into a support ticket or a chat with a colleague.

How do you use nethogs to find the busy process?

Run nethogs on the public interface and it lists each program with its PID, user, command line and current send and receive rates:

sudo nethogs eth0
sudo nethogs -d 2 eth0 wg0

-d 2 refreshes every two seconds, and naming several interfaces watches them together. While it runs, m cycles the units between rate, total kilobytes, total bytes and total megabytes, s sorts by sent traffic, r sorts by received traffic, and q quits. The total megabytes view is useful when a process sends in short bursts that a rate view hides.

nethogs matches packets to processes through their TCP sockets. Newer releases also count UDP when started with -C; check your version with nethogs -V and the man page before relying on it. Traffic that cannot be tied to a socket appears as unknown TCP, often from connections that closed a moment ago.

How do you log nethogs output for later?

Trace mode prints plain text instead of the interactive screen, which you can redirect to a file. This example takes thirty samples five seconds apart:

sudo nethogs -t -d 5 -c 30 eth0 | tee /tmp/nethogs.log

Each refresh writes one line per process with the program path, PID, UID, sent and received rates. Sort or filter the file afterwards with grep and awk. For anything longer than a few minutes, a proper monitoring stack such as Netdata records per interface history with far less effort than a looping nethogs.

What do you do once you find the culprit?

The answer depends on what you see. A backup or sync job that fills the link can be throttled: rsync accepts --bwlimit, and restic has --limit-upload. A single remote address sending floods of requests to your web server is a job for rate limiting or a ban, which the fail2ban guide covers. An unexpected process talking to unknown hosts is a security question: note the PID, inspect it with ps -fp PID and sudo ls -l /proc/PID/exe, and treat the server as possibly compromised if you did not start it.

If legitimate traffic keeps growing and your monthly allowance becomes tight, compare the outgoing transfer of the plans on the prices page; moving to a bigger plan follows the migration tutorial.

Why does iftop or nethogs show odd results?

A few situations come up often. If iftop shows nothing, check the interface name and that you used sudo. If the numbers look doubled, you are probably watching any or both a bridge and the physical interface, so watch one. Docker containers appear in nethogs under the process that owns the socket, which may be docker-proxy for published ports. Traffic inside a WireGuard tunnel shows as UDP to the tunnel peer on eth0; watch wg0 to see the inner flows.

Plans that fit this guide

Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.

All prices
PlanFits becauseSizeMonthlyOrder from
S1-2light sites where you only check traffic now and then1 vCPU, 2 GB RAM, 55 GB SSD$6.00/mo$72.00 for 12 months
A2-4busier hosts with more transfer per month2 vCPU, 4 GB RAM, 100 GB NVMe$14.40/mo$43.20 for 3 months

Questions about Live bandwidth with iftop and nethogs

Do iftop and nethogs count toward my monthly transfer?

They add no traffic of their own as long as name lookups are off (-n and -N in iftop). They only observe what already passes the interface.

Can I see monthly totals with these tools?

No. They show live rates and totals since start. Use vnstat as described in the usage monitoring tutorial for daily and monthly counters.

Why does nethogs show my process as unknown TCP?

The connection was gone before nethogs mapped it to a PID, or the socket lives in another network namespace. Longer lived flows are usually attributed correctly.

Is bits or bytes shown by default?

iftop shows bits per second unless you pass -B. nethogs shows kilobytes per second by default; press m to change units.

Do these tools work on FreeBSD?

iftop is available in FreeBSD packages, but nethogs is Linux only. This guide covers the Linux images.