Keeping track of how much internet data your server uses can be really helpful. I found this out while running a small web server at home. I wanted to make sure I didn’t go over my internet plan, and I was also curious how much traffic my websites were getting.
One tool I use for this is called vnStat.
vnStat is a lightweight program that watches how much data moves in and out of your network. It works in the background and doesn’t use much memory or CPU. It’s perfect if you want to track data usage over days, weeks, or even months.
In this article, I’ll show you how to install it, use it, and understand the numbers it shows. I’ll also explain a few terms that might sound new.
What is vnStat?
vnStat is a command-line tool. That means you use it by typing commands into a terminal. It doesn’t have a pretty window or a dashboard, but it does a great job.
It watches your network interface, like eth0
or wlan0
. This is just a fancy way of saying it checks the part of your computer that connects to the internet or your network.
vnStat keeps a small database with records of how much data goes in and out. It saves that info even after the computer restarts. That’s one reason I like it—it remembers.
Why Should You Use It?
Here are some reasons I started using vnStat, and maybe you will too:
- I wanted to see how much data my server used each day.
- I needed a simple way to log bandwidth without slowing things down.
- I didn’t want something that was hard to set up.
There are other tools, like iftop or Netdata, but many of them use more memory or show data in real-time only. vnStat gives me a history, and it works quietly in the background.
Installing vnStat
Let’s get started by installing it. I’ll use Ubuntu in this example, but you can also install it on CentOS, Debian, and others.
On Ubuntu or Debian:
sudo apt update
sudo apt install vnstat
On CentOS or RHEL:
sudo yum install epel-release
sudo yum install vnstat
After it installs, start the service:
sudo systemctl start vnstat
sudo systemctl enable vnstat
This makes sure it starts every time the computer boots.
Choosing the Right Interface
Your server might have more than one network interface. Some common ones are:
eth0
: Wired internetwlan0
: Wi-Fiens3
,enp0s3
, oreno1
: Newer naming for network devices
To see your interfaces, run:
vnstat --iflist
Pick the one that connects to the internet. On my server, it was eth0
.
You can then start tracking it with:
sudo vnstat -u -i eth0
After that, vnStat begins logging data.
Let It Run First
vnStat doesn’t show numbers right away. It needs time to collect data.
Give it a few minutes, or wait a day to get real stats. Then check usage with:
vnstat -i eth0
You’ll see something like:
rx / tx / total
today 230 MB / 120 MB / 350 MB
- rx: Data received (downloaded)
- tx: Data sent (uploaded)
- total: The sum of both
Simple, right?
Check Daily, Weekly, Monthly Use
vnStat can show more than just today’s traffic.
Here are a few handy commands:
- Daily usage:
vnstat -d
- Hourly usage:
vnstat -h
- Monthly usage:
vnstat -m
This helps if you’re watching for data caps. I used this to make sure I didn’t pass my 1 TB monthly plan.
Here’s what I like about vnStat:
- It doesn’t slow down your server.
- It keeps data even if you reboot.
- It’s super light and fast.
Output in a Clear Table
Sometimes the data looks better in a table format. You can use:
vnstat --style 2
This gives you a clean and neat table with aligned numbers. I find this easier to read.
Want to sort by months or days? Use:
vnstat -m --style 2
vnstat -d --style 2
You can even export the output to a file like this:
vnstat -m > usage_report.txt
Use vnStat as a Service
If you want vnStat to run all the time, make sure it’s active:
sudo systemctl enable vnstat
sudo systemctl start vnstat
To check if it’s working:
systemctl status vnstat
This will tell you if the service is running without errors.
Here are three ways I use vnStat in my daily server work:
- I log monthly data usage to see if I need a bigger hosting plan.
- I check hourly data during high traffic days to find peak hours.
- I compare download vs upload to spot odd behavior, like malware.
Compare with Other Tools
Let’s compare vnStat to other network tools:
Tool | Tracks History | Real-Time View | Easy to Use | Light on Resources |
---|---|---|---|---|
vnStat | ✅ Yes | ❌ No | ✅ Yes | ✅ Yes |
iftop | ❌ No | ✅ Yes | ✅ Yes | ⚠️ Medium |
nload | ❌ No | ✅ Yes | ✅ Yes | ✅ Yes |
Netdata | ✅ Yes | ✅ Yes | ❌ Hard | ⚠️ Heavy |
If you only need to see your internet usage over time, vnStat is often the simplest choice.
How to Reset Data
Want to start fresh? You can reset the database:
sudo vnstat -i eth0 --remove
sudo vnstat -u -i eth0
This clears all previous logs and starts again.
Be careful—this deletes everything.
Optional: Use vnStati for a Graph
If you prefer graphs, there’s a tool called vnStati
that works with vnStat.
Install it with:
sudo apt install vnstati
Then make a PNG graph like this:
vnstati -s -o ~/network.png
This creates a summary image you can check anytime.
I sometimes set this up to email me the image once a week.
Final Thoughts
vnStat is one of those tools I didn’t know I needed—until I tried it. Now I use it all the time.
It helped me learn more about how my server uses the internet. I could see when people visited my site most. I could also check if anything strange was using my bandwidth.
You don’t need to be an expert to use it. The commands are simple. The info it gives is clear. And it runs quietly in the background.
Have you tried vnStat before? Or do you use something else?
If you’re just starting with servers or want a better way to track usage, I think vnStat is a good tool to try.
Would you like me to show you how to set alerts if usage goes over a limit?