October 15, 2018

How to Install vnStat on FreeBSD

FreeBSD Logo

vnStat is a useful tool to keep track of your network traffic for selected interfaces. By using the kernel network interface statistics this tool ensures light use of system resources. vnStat is open source and can be installed through a FreeBSD port.

Root access is required to edit the following files and to execute commands. Log in as root (su) or simply prepend sudo to all commands that require root privileges.

Installing vnStat on FreeBSD

Navigate to the port directory and install vnStat with the following commands:

cd /usr/ports/net/vnstat
make install clean; rehash

I have choosen the default installation options without X11.

Configure vnStat on FreeBSD

First you need to know the name of your network interfaces.

ifconfig -a

Create the directory for the log files.

mkdir /var/db/vnstat

The following command will create the vnStat database for the given network device. Please replace bge0 with your network interface name.

vnstat -u -i bge0

Set vnStat cron job on FreeBSD

The cron job will collect the network stats.

cat /usr/local/share/doc/vnstat/vnstat-cron >> /etc/crontab

Using vnStat on FreeBSD

Now, you can use vnStat by typing the following command into the console. Please replace bge0 here with your network interface name as well. This command will show you the current transfer rate of your network device.

vnstat -i bge0 -l

Please click here to view more options.

Speak Your Mind