[H-GEN] Bandwidth logging of internet broadband for local network

Paul Gearon pag at PISoftware.com
Tue Feb 19 23:30:12 EST 2002


[ Humbug *General* list - semi-serious discussions about Humbug and  ]
[ Unix-related topics.  Please observe the list's charter.           ]
[ Worthwhile understanding: http://www.humbug.org.au/netiquette.html ]

On Tue, 19 Feb 2002, Matthew Sellers wrote:

> I am trying to find information on ways to measure the bandwidth used by
> individual clients for a shared broadband internet connection.
> So far I have only been able to find information on how to set up a shared
> internet connection, nothing on how to measure it.
>
> Ideally I am trying to find a program that measures the traffic originating
> from and going to the internet for several clients in order to avoid
> exceeding the usage cap.

There've been a few other suggestions, but I'd be inclined to try using
iptables (if you're running a 2.4.x kernel or higher) with a ULOG target
(not enabled by default, but easy enough to put in  :-)

You can then run ulogd to log the packets to a file, syslog, or mySQL.
Debian has ulogd and ulogd-mysql packages (I assume it's readily available
for other distros).

So if you're local network were on eth0, and the internet were on eth1 you
could try:

iptables -A INPUT -i eth0 -o eth1 -j ULOG

This logs to netlink port 1 by default (use --ulog-nlgroup <nlgroup> to
change it).  You can then set up the ulog daemon.

Alternatively if you know the ip addresses, you can even split it up a
little more with iptables by saying:

iptables -A INPUT -i -s 192.168.105.1 -o eth1 -j ULOG --ulog-prefix "fred"
iptables -A INPUT -i -s 192.168.105.2 -o eth1 -j ULOG --ulog-prefix "wilma"
iptables -A INPUT -i -s 192.168.105.3 -o eth1 -j ULOG --ulog-prefix "barney"
iptables -A INPUT -i -s 192.168.105.4 -o eth1 -j ULOG --ulog-prefix "betty"


Maybe the other methods already mentioned are more appropriate, but
getting all this stuff working is fun.  :-)

Regards,
Paul Gearon

Software Engineer                Telephone:   +61 7 3876 2188
Plugged In Software              Fax:         +61 7 3876 4899
http://www.PIsoftware.com        PGP Key available via finger

Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum
immane mittam.
(Translation from latin: "I have a catapult. Give me all the money,
or I will fling an enormous rock at your head.")



--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.



More information about the General mailing list