Managing vnstat effectively is a crucial skill for any system administrator. This tutorial provides step-by-step instructions for bandwidth configuration, along with best practices for production environments.
Network Configuration
Performance benchmarks show that properly tuned vnstat can handle significantly more concurrent connections than the default configuration. The key improvements come from adjusting worker processes and connection pooling.
# Network configuration and testing
ip addr show # View interfaces
ip route show # View routing table
ss -tlnp # View listening ports
# Firewall rules
sudo iptables -L -n -v # List current rules
sudo ufw status verbose # UFW status
The output should show the service running without errors. If you see any warning messages, address them before proceeding to the next step.
Firewall Rules Setup
The default configuration works well for development environments, but production servers require additional tuning. Pay particular attention to connection limits, timeout values, and logging settings.
# Configure network interface
sudo nano /etc/netplan/01-netcfg.yaml
network:
version: 2
ethernets:
eth0:
addresses:
- 192.168.1.10/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 1.1.1.1
sudo netplan apply
Make sure to restart the service after applying these changes. Some settings require a full restart rather than a reload to take effect.
Conclusion
This guide covered the essential steps for working with vnstat on a VPS environment. For more advanced configurations, refer to the official documentation. Don't hesitate to reach out to our support team if you need help with your specific setup.