How To's Linux Networking

How to Monitor Network Traffic with vnStat in Ubuntu

vnStat is an open source network monitoring tool and network traffic logger for any selected network interface (eth0, wlan0, etc.). It allows to sniff and gather data from multiple interfaces at the same time by avoiding the abuse of system resources.
vnStat can be easily installed in a Linux-based system and it requires at least kernel 2.2 to run. This tool can be used with or without root privileges.
vnStat Installation (Console Mode)
To install vnStat on Ubuntu, run this command:

sudo apt-get install vnstat libgd2-xpm

Let’s now create the database where traffic data will be stored into (For my part, I will monitor my wired network connection: “eth0”, but you can change it to your own network interface —> eth1, eth2, etc.):

sudo vnstat -u -i eth0

For wireless connections, use this command (wlan0, wlan1, etc.):

sudo  vnstat -u -i wlan0

Wait now at least five minutes while network traffic data are being gathered, then run this command to start monitoring:


vnStat Installation (Graphic Mode)
To use vnStat via a graphical interface, then follow these steps:
1. Open the Terminal and install first PHP5 and Apache2 using these commands:

sudo apt-get install php5
sudo apt-get install apache2
sudo /etc/init.d/apache2 restart

2. Run now this command:

cd /var/www

3. Inside this folder (/var/www) run these commands to download and unpack the script files (root permissions required):

sudo wget
sudo tar xvzf vnstat_php_frontend-1.4.1.tar.gz
sudo mv vnstat_php_frontend-1.4.1 vnstat

4. You can then access the web interface via one of these two links:


Post Comment