I often need to know how much bandwidth is my linux gateway/router box using, specially if there’s any P2P traffic (torrents) and from which IP address on the LAN is it coming. I was searching a lot for a suitable and preferably web based bandwidth monitoring tool, at the end I came up with a program called Bandwidthd that does data collection on it’s own (not SNMP) on the specified interfaces and subnets, and push them in dynamic html pages, with a top list of bandwidth users on your LAN network, what type of traffic are they using (http, p2p, ftp, etc) and apropriate graphs for all of the mentioned.

Initially, it’s not suited for a Centos box, but it’s installable. First, we need the development tools installed:

yum groupinstall ‘Development Tools’

Then a few more packages: libpcap – you can download it from here, then unpack, enter it’s folder, compile and install:

./configure
make
make install

Another package you need is GD, it should be available from the standard repo:

yum install gd gd-devel php-gd

The third package is libpng, also should be available from the repo:

yum install libpng-devel After all the packages are installed, we can try to download the Bandwidthd code and try to compile it. Find the latest release from here, wget and uncompress it, enter it’s folder, and standardly compile it:

./configure
make
make install

All should go smooth, without errors.

Configuring Bandwidthd

We have a few more steps to deploy. First we need to configure Bandwidthd:

vi /usr/local/bandwidthd/etc/bandwidthd.conf

make the options look something like this (there is an extensive explanation in the config file itself about the meaning of each):

subnet <the subnet you wish track>
subnet <if you have another subnet….>
dev “eth0”
skip intervals 0
graph_cutoff 1024
filter “ip”
graph true
meta_refresh 150

Save and exit. BTW, you can add more subnets, as many as you like.  And, under dev, you must enter the proper eth port that you want to use for traffic capture (usually the on on the LAN side) The only thing left is to add an alias for confortable use:

vi /etc/httpd/conf.d/bw.conf

and add at least the line:

alias /bw /user/local/bandwidthd/httpdocs

Save, and exit. Now, start bandwidthd

./usr/local/bandwidthd/bandwidthd

You can add this line to rc.local to make it start on boot. At end, point your web browser to http://<server_ip_address or url>/bw Data should start comming in a few minutes.

One thought on “Web based bandwidth monitoring on a Linux gateway

  1. I actually wanted to develop a small note to thank you for all of the nice tips and hints you are showing at this site. My time intensive internet look up has at the end been compensated with reputable know-how to go over with my classmates and friends. I would tell you that many of us website visitors actually are quite blessed to dwell in a notable site with many wonderful people with very helpful hints. I feel pretty privileged to have come across your entire webpage and look forward to really more excellent moments reading here. Thanks once more for all the details.

Leave a Reply to Hairstyles Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.