brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: iftop -n -P shows which connections use your bandwidth

Linux
~/tips/tip-networking-iftop-n-p

sudo iftop -n -P -i eth0

Shows live traffic per connection on an interface, with numeric hosts and ports.

When the internet feels slow I want one answer: who is talking, and to whom? iftop is top for network connections. Each line is a pair of hosts and how much data flows between them right now.

sudo iftop -n -P -i eth0

-n skips hostname lookups, which keeps the screen quick and stops iftop from generating DNS traffic of its own. -P turns on port display, so you see the port next to each address. -i picks the interface, and the name differs per machine.

The three columns on the right are the average rate over the last 2, 10 and 40 seconds, sorted by the 10-second one. A few keys help while it runs:

  • s and d group all traffic per source or per destination.
  • p switches port display on and off.
  • 1, 2 and 3 sort by that column.
  • P pauses the screen, which is useful when you want to copy an address.

To only count one network, use -F with a network and mask. The man page gives -F 10.0.0.0/255.0.0.0 as an example.

The caveat: it needs permission to see all traffic on the interface, which normally means root. It also shows connections, not processes. For the program behind the traffic you need a tool like nethogs.

Further reading: iftop man page

Going deeper: Keep a domain pointed at your home with Cloudflare DDNS on Unraid

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link