Nameless

Member
Feb 25, 2003
17
0
151
Hello.
I have server with installed FreeBSD and CPanel. I also want to see how we are use our trafik. Our ISP don't provide for us consuption of trafik, so i tried to install bandmin to my server. But by default, bandmin doesn't support FreeBSD and therefore i made some modifications on it and add support for ipfw. Modified version can be downloaded here:
http://www.baf.ru/files/unix/freebsd/misc/bandmin-freebsd.tar.bz2
How to install.

WARNING! This is not original version of bandmin. I do some modifications with it, and i'm not sure
that it will works on the LINUX systems(i don't check it), for LINUX systems, use please bandmin
from CPanel distributions.

1. Unpack bandmin into /usr/local/bandmin. If you unpack it to another place,then you should change
all paths in its files(bandmin.sh, bandminstop, etc.) to yours.

2. You should recompile your kernel with ipfw support. Add these options to your kernel and
recompile it as described in handbook.
options IPFIREWALL #firewall
options IPFIREWALL_VERBOSE #enable logging to syslogd(8)
options IPFIREWALL_DEFAULT_TO_ACCEPT #allow everything by default

If you are not familiar with firewall in FreeBSD use default for accept options. Otherwise, if
you setup incorrect rules for ipfw, after enabling it you can't login to your server.

3. After recompiling and installing new kernel, enable ipfw in rc.conf file. Edit /etc/rc.conf and
add these lines:
firewall_enable="YES"
firewall_script="/etc/firewall"

Create file /etc/firewall and add to it your rules. By default, ipfw add rules through 100. I use
following:
/sbin/ipfw add pass all from any to any via lo0
/sbin/ipfw add deny all from any to 127.0.0.0/8
/sbin/ipfw add deny ip from 127.0.0.0/8 to any
/sbin/ipfw add reject tcp from any to any 113
# other your rules..
# rules with number 1 and 1500 is used by bandmin. Don't use these numbers.
#

/sbin/ipfw add 5000 pass all from xx.xx.xx.xx to me
/sbin/ipfw add 5100 pass all from me to xx.xx.xx.xx
/sbin/ipfw add 65500 drop log all from any to any

First rule(pass all from any to any via lo0) will has number 100, second rule(deny all from any to
127.0.0.0/8) will has number 200, etc. Rules with number 1,1500 is used by bandmin, but you can
change these values. Replace xx.xx.xx.xx with your real IP address(with address wich you use for
login to SSH and WHM).
4. Go to /usr/local/bandmin/IP and edit file Acct.pm. You should setup correct value for
$IFACE(outgoing interface for your server, can be fxp0, rl1, sis0, de0 etc.), and setup correct
value for $MYIP(outgoing IP address for your server).

5. Edit /usr/local/bandmin/services.conf and add or remove used/unused services.

6. Copy bandmin.sh to /usr/local/etc/rc.d and change permissions on it to 755:
chmod 755 bandmin.sh

7. Add line:
Alias /bandwidth/ /usr/local/bandmin/htdocs/
to your httpd.conf file

8. Run cron_install script. It add some commands to crontab
./cron_install

9. After this, you can reboot server with new kernel. After rebooting, open in your browser this
URL:

http://yourserverdomain/bandwidth/

there you can see trafik for your server.
I test it on my FreeBSD 4.9-RELEASE-p1. Can anybody compare bandmin results with hardware trafik counter?
Be carefull when install it, probably i forget describe something :rolleyes: and sorry for my english :)
 

PbG

Well-Known Member
Mar 11, 2003
249
0
166
Is there a bandmin equivalent for FreeBSD that works on a Cpanel box?
 

Nameless

Member
Feb 25, 2003
17
0
151
Originally posted by PbG
Is there a bandmin equivalent for FreeBSD that works on a Cpanel box?
It's bandmin with some modifications, which allow it run under FreeBSD.