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:

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.):

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

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:

2. Run now this command:

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

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

I started blogging around 2011 at #Ubuntupirates, #ProjectX and #pir8geek, I’m currently working as Network/Linux SysAdmin.

I’m a Linux,opensource advocate and interested in network security and InfoSec.

Leave a Reply