I am using vnstat
for first time and I am getting this error while using vnstat -d
Error: Unable to read database "/var/lib/vnstat/eth0": No such file or directory
The file in /var/lib/vnstat
are
enp1s0 wlp2s0
These are my network interfaces.
I can understand it using eth0
file but how can I changed default file to enp1s0
from eth0
.
When I use sudo vnstat -u -i eth0
, I get error
Error: Unable to read database "/var/lib/vnstat/eth0": No such file or directory Error: Unable to get interface "eth0" statistics. Only available interfaces can be added for monitoring.
The default interface is defined in the
/etc/vnstat.conf
file:Although you could change it there, a possibly better way is to create your own
~/.vnstatrc
file and modify that:then use an editor of your choice to change
Interface "eth0"
toInterface "enp1s0"
in the local copy.See
man vnstat.conf
for full details.I solved the issue by changing
interface
in the file/etc/vnstat.conf
frometh0
towlp3s0
. If you don't know your network interfaces, you could get by the commandip addr
.Many parson answers correctly but missing one more thing
Needs to change configuration in two places
/etc/vnstat.conf
andHOME Directory/.vnstatrc
(Ex./home/sagar/.vnstatrc
)Change default interface from eth0 to whatever in your machine like
enp1s0
orwlp2s0
orwlp3s0
In both files statment will be like
Interface "wlp3s0"
Save file and check again useing coommend
vnstat -d
Please start first vnstat service. No matter if configuration (/etc/vnstat.conf or ~/.vnstatrc) is edited or NOT.