Traffic and Bandwidth Monitoring

01

vnstat: Historical Bandwidth Consumption

vnstat records traffic over time and allows you to see how many GB you've consumed per day, week, or month. Perfect for keeping track of monthly traffic included in your plan.

Installation

bash
apt install vnstat -y         # Debian/Ubuntu
dnf install vnstat -y         # CentOS/AlmaLinux

systemctl enable --now vnstat

Usage

bash
# General summary
vnstat

# Hourly traffic (last 24 hours)
vnstat -h

# Daily traffic
vnstat -d

# Weekly traffic
vnstat -w

# Monthly traffic
vnstat -m

# Continuous update every 5 seconds
vnstat -l

# Specify the interface (e.g., eth0, ens3)
vnstat -i eth0 -m

Find Your Network Interface Name

bash
ip link show
# or
vnstat --iflist
02

iftop: Real-time Traffic per Connection

iftop shows active connections and their bandwidth consumption in real-time. Useful for quickly understanding who's using lots of bandwidth.

bash
apt install iftop -y

# Start (requires root)
iftop

# On specific interface
iftop -i eth0

# Show ports
iftop -P

Useful keys inside iftop:

  • n: show/hide DNS resolution
  • p: show/hide ports
  • s: sort by source
  • d: sort by destination
  • q: exit
03

nethogs: Traffic per Process

nethogs associates network traffic with individual processes or applications. Ideal for understanding which program is consuming bandwidth.

bash
apt install nethogs -y

nethogs
nethogs eth0    # On specific interface

Example output:

NetHogs version 0.8.7 PID USER PROGRAM DEV SENT RECEIVED 1234 www-data nginx eth0 1.2 MB 0.3 MB 5678 root sshd eth0 0.1 MB 0.0 MB
04

nload: Real-time Speed per Interface

nload shows current upload and download speed with a graphical bar:

bash
apt install nload -y
nload
05

Quick Check Without Additional Tools

If you don't want to install anything:

bash
# Traffic on interface every second (RX = received, TX = sent)
watch -n 1 cat /proc/net/dev

# Active connections and count per IP
ss -tn | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -rn | head -20

# How many connections per state (ESTABLISHED, TIME_WAIT, etc.)
ss -tan | awk '{print $1}' | sort | uniq -c | sort -rn
06

Check Total Bandwidth Consumption

If your plan has a monthly traffic limit, you can monitor it with vnstat:

bash
# Current month's traffic
vnstat -m | grep "$(date +%Y-%m)"

The VirtFusion panel also shows traffic graphs over time in the Graphs section. See: Statistics and Graphs

DeluxHost, fondata nel 2023, offre soluzioni di hosting di alta qualità per diverse esigenze digitali. Forniamo hosting condiviso, VPS e server dedicati con sicurezza avanzata e datacenter globali.

© DeluxHost, Tutti i diritti riservati. | Partita IVA: IT17734661006
Tutti i sistemi operativi