Install vnStat network traffic monitor on Debian 11

This guide is going to take you through on how to Install vnStat network traffic monitor on Debian 11. vnStat is a network tool for the Linux operating system that monitors network traffic using a command line interface, or console. vnStat keeps a track of network traffic for the selected interfaces on an hourly, daily, and monthly basis.

How to Install vnStat network traffic monitor on Debian 11

  • Update your packages.
sudo apt update
  • Install vnStat network traffic monitor on Debian 11.
sudo apt install vnstat

Sample output

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bc cups cups-browsed cups-client cups-core-drivers
  cups-daemon cups-filters cups-filters-core-drivers
  cups-ipp-utils cups-ppdc cups-server-common fonts-symbola
  hyphen-en-us iw javascript-common libcupsfilters1
  libfontembed1 libglu1-mesa liblouisutdml-bin
  liblouisutdml-data liblouisutdml9 libpoppler-cpp0v5
  libqpdf28 libreoffice-help-common libreoffice-help-en-us
  mythes-en-us node-normalize.css sudo x11-apps
  x11-session-utils xinit
Use 'sudo apt autoremove' to remove them.
Suggested packages:
  vnstati
The following NEW packages will be installed:
  vnstat
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 96.7 kB of archives.
After this operation, 278 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main amd64 vnstat amd64 2.6-3 [96.7 kB]
Fetched 96.7 kB in 0s (213 kB/s)
Selecting previously unselected package vnstat.
(Reading database ... 143627 files and directories currently installed.)
Preparing to unpack .../vnstat_2.6-3_amd64.deb ...
Unpacking vnstat (2.6-3) ...
Setting up vnstat (2.6-3) ...
Created symlink /etc/systemd/system/multi-user.target.wants/vnstat.service → /lib/systemd/system/vnstat.service.
Processing triggers for man-db (2.9.4-2) ...

Configure vnStat on Debian 11

  • A default database directory for each interface will be created at /var/lib/vnstat after installation. The command below will list the contents of the directory.
ls -l /var/lib/vnstat/
  • Use the following command to find out what your interface’s name is.
ip l show

Sample output

1: lo:  mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33:  mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:0c:29:e6:b6:d0 brd ff:ff:ff:ff:ff:ff
    altname enp2s1
  • In the vnstat config file, provide the name of the interface you want to monitor. Use the command below to open the file.
sudo nano /etc/vnstat.conf
  • After that, type in the name of your interface. Replace ‘ens33’ with the name of your interface, save, and exit the file.
Interface "ens33"
  • To apply the changes, restart vnStat.
sudo systemctl restart vnstat
  • Check status.
sudo systemctl status vnstat.service

Sample output

● vnstat.service - vnStat network traffic monitor
     Loaded: loaded (/lib/systemd/system/vnstat.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-04-28 21:38:14 EAT; 8s ago
       Docs: man:vnstatd(8)
             man:vnstat(1)
             man:vnstat.conf(5)
   Main PID: 5668 (vnstatd)
      Tasks: 1 (limit: 4623)
     Memory: 604.0K
        CPU: 46ms
     CGroup: /system.slice/vnstat.service
             └─5668 /usr/sbin/vnstatd -n

Apr 28 21:38:14 debian systemd[1]: Started vnStat network traffic monitor.
Apr 28 21:38:15 debian vnstatd[5668]: Info: vnStat daemon 2.6 started. (pid:5668 uid:125 gid:132 64-bit)
Apr 28 21:38:15 debian vnstatd[5668]: Info: Monitoring (1): ens33 (1000 Mbit)

View Network Traffic on Debian 11

  • Run the following command to see real-time network traffic. Replace ens33 with the name of your interface.
vnstat -i ens33 -l

Sample output

Monitoring ens33...    (press CTRL-C to stop)

   rx:   197.92 kbit/s    77 p/s          tx:    83.66 kbit   rx:     1.80 kbit/s     3 p/s          tx:     7.86 kbit   rx:    10.22 kbit/s    14 p/s          tx:     7.27 kbit   rx:     2.31 kbit/s     4 p/s          tx:     2.92 kbit   rx:     7.92 kbit/s     9 p/s          tx:    11.75 kbit   rx:     8.59 kbit/s    15 p/s          tx:     6.78 kbit   rx:    31.22 kbit/s    25 p/s          tx:    27.28 kbit   rx:     1.08 Mbit/s   191 p/s          tx:   296.65 kbit   rx:     3.02 Mbit/s   399 p/s          tx:   535.31 kbit   rx:     1.32 Mbit/s   254 p/s          tx:   366.27 kbit   rx:     1.30 Mbit/s   233 p/s          tx:   430.76 kbit   rx:   232.99 kbit/s    92 p/s          tx:   252.22 kbit   rx:   452.93 kbit/s   146 p/s          tx:   293.23 kbit   rx:   242.45 kbit/s    84 p/s          tx:   110.99 kbit   rx:    27.66 kbit/s    27 p/s          tx:    31.14 kbit/s    27 p/s^C


 ens33  /  traffic statistics

                           rx         |       tx
--------------------------------------+------------------
  bytes                     2.90 MiB  |        0.98 MiB
--------------------------------------+------------------
          max            3.02 Mbit/s  |   535.31 kbit/s
      average          391.93 kbit/s  |   133.05 kbit/s
          min                0 bit/s  |         0 bit/s
--------------------------------------+------------------
  packets                       5034  |            4525
--------------------------------------+------------------
          max                399 p/s  |         267 p/s
      average                 81 p/s  |          72 p/s
          min                  0 p/s  |           0 p/s
--------------------------------------+------------------
  time                  1.03 minutes
  • Use the command below to see hourly traffic.
vnstat -h

Sample output

ens33  /  hourly

         hour        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     2022-04-28
         21:00      4.29 MiB |    1.48 MiB |    5.77 MiB |   18.63 kbit/s
     ------------------------+-------------+-------------+---------------
  • The command below will show you daily network traffic.
vnstat -d

Sample output

ens33  /  daily

          day        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     2022-04-28     4.63 MiB |    1.69 MiB |    6.31 MiB |      676 bit/s
     ------------------------+-------------+-------------+---------------
     estimated      5.11 MiB |    1.86 MiB |    6.97 MiB |
  • View the Monthly Traffic Report
vnstat -m

Sample output

ens33  /  monthly

        month        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
       2022-04      4.63 MiB |    1.69 MiB |    6.31 MiB |       21 bit/s
     ------------------------+-------------+-------------+---------------
     estimated      4.94 MiB |     --      |    4.94 MiB |
  • View the Traffic Report for the Month.
vnstat --help
  • That marks the end of our article, Cheers. You have learned how to Install vnStat network traffic monitor on Debian 11.

Read more about vnStart

Other Tutorials

Install WPS Office on Debian 11/Debian 10

Install WPS Office on Fedora 35

Configure Static IP Address on Ubuntu 22.04

System administrator | Software Developer | DevOps

Leave a Comment