Skip to content

How to Monitor Network Traffic with vnStat on CentOS and Fedora

Setup vnStat, Vnstat is an utility counts bandwidth on network interface. How to Monitor Network Traffic with vnStat on CentOS and Fedora

Steps
3
Covers
CentOS, Fedora, PHP
Versions & support
About PHP →, About CentOS →
On this page 3 steps

vnStat is a network traffic monitoring tool for Linux systems. It is used to track the network traffic data and display it in a convenient graphical interface. vnStat can be used to track bandwidth usage on a per-interface basis, which makes it an ideal tool for monitoring network traffic on servers, routers, and other network devices. This article provides a comprehensive guide on how to set up vnStat on CentOS and Fedora systems.

Prerequisites

Before installing vnStat, make sure that your system meets the following requirements:

  • A running CentOS or Fedora system
  • A user with administrative or root privileges

Step 1 of 3Installing vnStat

  1. Update the system’s package index by running the following command:
    sudo yum update 
    
  2. Install the vnStat package by running the following command:
    sudo yum install vnstat 
    
  3. Once the installation is complete, start the vnStat service by running the following command:
    sudo systemctl start vnstat 
    
  4. Enable the vnStat service to start automatically at boot time by running the following command:
    sudo systemctl enable vnstat 
    

Step 2 of 3Configuring vnStat

  1. To configure vnStat, open the configuration file using your favorite text editor, for example:
    sudo nano /etc/vnstat.conf 
    
  2. In the configuration file, set the desired options, such as the location of the database file, the polling interval, and the interface to be monitored. For example, to monitor the “eth0” interface set the following option:

  3. Save the changes and close the file.

Step 3 of 3View Network Traffic Statistics

You should wait for some time to let the vnStat collect data for the defined interface. After that, you can view the statics on the command line interface.

  • To check the network traffic data, run the following command:
    vnstat 
    
    Output
    Database updated: 2023-02-07 18:30:00 eth0 since 2023-02-07 rx: 686.41 KiB tx: 5.20 MiB total: 5.87 MiB monthly rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- 2023-02 686.41 KiB | 5.20 MiB | 5.87 MiB | 84 bit/s ------------------------+-------------+-------------+--------------- estimated 2.31 MiB | 20.76 MiB | 23.07 MiB | daily rx | tx | total | avg. rate ------------------------+-------------+-------------+--------------- today 686.41 KiB | 5.20 MiB | 5.87 MiB | 739 bit/s ------------------------+-------------+-------------+--------------- estimated 890 KiB | 6.74 MiB | 7.61 MiB |

    The vnStat output will display the network traffic data for the specified interface in a graphical format, including the total amount of data received and transmitted, the total number of packets received and transmitted, and the average transfer rate.

  • You can also view the statistics for a specific time period, such as daily, weekly, monthly, and yearly, by running the following command:
    vnstat -d 
    vnstat -w 
    vnstat -m 
    vnstat -y 
    
  • You can also view the network statics in real-time with the following command.
    vnstat -l 
    

Conclusions

vnStat is a simple and lightweight tool for monitoring network traffic on Linux systems. With the help of this article, you should now be able to install and configure vnStat on CentOS and Fedora systems. The tool is highly customizable and provides a graphical representation of network traffic data, making it easy to understand and analyze network usage patterns. With vnStat, you can monitor network traffic on servers, routers, and other network devices, and ensure that your network is running smoothly.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

8 Comments

  1. Hi Folks ,
    Thank you for amazing pretty tool article.
    i have a question.
    i installed my centos 6 x64 cPanel WHM server but . Getting Internal Server Error
    But everythings looks normal.
    What can i do ?
    Thanks in advance.
    Regards.
    Berk

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top