DESCRIPTION
Banjar stands for bandwidth justification for administrator, an open source software that provides simple bandwidth management tools for internet cafe or small to medium network administrators.
Banjar will manage your uplink and downlink bandwidth, let you define your networks and packages and then limit bandwidth for each of those packages on each networks. For Indonesian, you will find this tool useful as it separates IIX bandwidth and International bandwidth. Easy application to install and operate.
LICENSE
LGPL as in GNU Lesser General Public License. In short, you can include Banjar as a library into your own application, re-publish it, modify it, change it, use it, sell it, for free or paid. You don’t need to provide the source code when using Banjar with your own software or any other software. Only when you modify Banjar source codes, you will have to provide those modifications accessible for public.
CONTRIBUTORS
Main developer is Anton Raharja (me me mee..). Once I got helps from Abdul Hanan and Moses Kurniawan, mostly for web UI stuffs. Every now and then WAN-DKI team (Asoka, Engkos, Dedi, Husen, Sindu, Imam) helps in a way that they can do best, bug me to code fixes, updates and more features !
REQUIREMENTS
Below are software required to install Banjar. Most of them are already available on main stream Linux distros.
- Linux (any linux capable of running iptables and tc with HTB)
- Apache (any version, not tested on other web server)
- MySQL or Sqlite3 (the default is Sqlite3)
- PHP4 or PHP5 (wrote on php4 but will work on php5)
- PHP PEAR and PEAR-DB
- iptables (load connmark modules, automatic on most distros)
- tc (iproute2 package)
- cron (scheduler for writing rules to a shell script and execute them automatically)
- svn (subversion package, this is optional, only for brave linux admin)
You may continue to installation part after all requirements above met.
INSTALLATION
Download the latest package from SourceForge, current release is Banjar version 0.8.1, and then extract it. But if you want the latest development you can get the code from Peanut Inc. SVN repository.
Follow steps below to get the latest source code from Peanut Inc. SVN repository:
Steps:
# mkdir -p /usr/local/src/svn
# cd /usr/local/src/svn
# svn co http://developer.peanutinc.com/svn/banjar/trunk banjar
# cd banjar
There are 2 (two) available alternatives to install, each of them having no more than 11 (eleven) steps to follow, most of them are usual steps to install PHP based applications.
The first is to use Sqlite3 as a back-end database and the second would be to use MySQL. Chose one of two.
Alternative 1 is suitable for production bandwidth manager routers where you don’t want to burden your machine with a full featured database engine like MySQL. Using Sqlite3 will reduce the need to use high-end PC for Linux routers as it just a text-file database, no sockets opened, no daemon running. But then I never conducted any benchmark, so don’t take my word for granted, please do your own tests.
Note:
All those chmod 666 or 777 below is considered not safe, for those who understands, please use chown to web server’s user and group instead.
ALTERNATIVE 1: USING SQLITE3 AS BACK-END DATABASE
- Install Sqlite3 (tested on 3.4.2) on Ubuntu (tested on 7.10).
Steps:
# apt-get install sqlite3 php-pear php-db php5-sqlite3 - Copy files and directories here to a directory under Web Server’s document root.
Note:- For debian or ubuntu the default document root is /var/www
- For redhat based distro the default document root is /var/www/html
- For suse the default document root is /srv/www/htdocs
- In this manual we are using ubuntu server, the document root is /var/www
Steps:
# cd [this package directory]
# mkdir /var/www/banjar
# cp -rR . /var/www/banjar - Copy necessary files and directories to non-web-document-root directory.
Steps:
# cd [this package directory]
# cp -rR ./docs/root/banjar /etc
# cp -rR ./docs/root/sbin /usr/localNote:
Rules (netfilter.*) will be in /etc/banjar and the executor (banjar.sh) in /usr/local/sbin - Copy sqlite3 database to /etc/banjar/.
Steps:
# cd [this package directory]
# cp ./docs/db/sqlite3/banjar.db /etc/banjar/
# chmod 666 /etc/banjar/banjar.db - Copy directory conf.example to conf.
Steps:
# cd [this package directory]
# cp -r conf.example conf - Edit conf/config.php (self explanatory, please pay attentions to comments).
Steps:
# cd [this package directory]
# mc -e conf/config.php
or
# vi conf/config.php
or
# nano conf/config.phpNote:
You may also want to edit other important files, they are:- conf/config_bandwidth.php
- conf/config_password.php
- /etc/banjar/netfilter.masquerade
- We need 666 permission for config_bandwidth.php and netfilter.*
Steps:
# cd [this package directory]
# chmod 666 config_bandwidth.php
# chmod 666 /etc/banjar/netfilter.* - Change banjar.sh permission to 777.
Note:
You may want to take a look at config.php, see $apps_path[‘netfilter_exec’] and remember which filename used as netfilter execution file and its path, the default is banjar.shSteps:
# chmod 777 /usr/local/sbin/banjar.sh - Configure crontab file.
Note:
As root type: crontab -e, this will open a crontab editorSteps:
# crontab -e - Insert on crontab editor: * * * * * /usr/local/sbin/banjar.sh >/dev/null 2>&1
Note:
This entry will automate the execution of /usr/local/sbin/banjar.sh every 1 (one) minute. This step is very important, without this Banjar will never automatically execute any changes. - Browse Banjar web panel and login (admin login is on config_password.php), the default would be:
- username = admin
- password = secret
ALTERNATIVE 2: USING MYSQL AS BACK-END DATABASE
Note:
If you already choose to use ALTERNATIVE 1, you don’t have to follow below steps.
- Copy files and directories here to a directory under Web Server’s document root.
Note:- For debian or ubuntu the default document root is /var/www
- For redhat based distro the default document root is /var/www/html
- For suse the default document root is /srv/www/htdocs
- In this manual we are using ubuntu server, the document root is /var/www
Steps:
# cd [this package directory]
# mkdir /var/www/banjar
# cp -rR . /var/www/banjar - Copy necessary files and directories to non-web-document-root directory.
Steps:
# cd [this package directory]
# cp -rR ./docs/root/banjar /etc
# cp -rR ./docs/root/sbin /usr/localNote:
Rules (netfilter.*) will be in /etc/banjar and the executor (banjar.sh) in /usr/local/sbin - Insert SQL statements from directory docs/db (banjar.sql) to a MySQL database.
Steps:
# cd [this package directory]
# mysqladmin -p create banjar
# mysql -p banjar < ./docs/db/banjar.sql - Copy directory conf.example to conf.
Steps:
# cd [this package directory]
# cp -r conf.example conf - Edit conf/config.php (self explanatory, please pay attentions to comments).
Steps:
# cd [this package directory]# mc -e conf/config.php
or
# vi conf/config.php
or
# nano conf/config.phpNote:
You may also want to edit other important files, they are:- conf/config_bandwidth.php
- conf/config_password.php
- /etc/banjar/netfilter.masquerade
- We need 666 permission for config_bandwidth.php and netfilter.*
Steps:
# cd [this package directory]
# chmod 666 config_bandwidth.php
# chmod 666 /etc/banjar/netfilter.* - Change banjar.sh permission to 777.
Note:
You may want to take a look at config.php, see $apps_path[‘netfilter_exec’] and remember which filename used as netfilter execution file and its path, the default is banjar.shSteps:
# chmod 777 /usr/local/sbin/banjar.sh - Configure crontab file.
Note:
As root type: crontab -e, this will open a crontab editorSteps:
# crontab -e - Insert on crontab editor: * * * * * /usr/local/sbin/banjar.sh >/dev/null 2>&1
Note:
This entry will automate the execution of /usr/local/sbin/banjar.sh every 1 (one) minute. This step is very important, without this Banjar will never automatically execute any changes. - Browse Banjar web panel and login (admin login is on config_password.php), the default would be:
- username = admin
- password = secret
That’s all folks. Installing is harder than using it, don’t wait up until my next article coz there may be a chance I won’t even write it 🙂
Enjoy!
dear sir
Irealy serious get full information about voip rakyat that w’d aplicated on between my company to the other brands company.
c’d you inform simplefy what I shoud do including
soft and hardware for start.
thanks
yours sincerly:
Madekan Saroni Urip
the article is about banjar 🙂 read the article before posting comments will ya..
if you’re serious enough to know voip stuffs, go to http://voiprakyat.or.id/forum/
really nice work, saluuute 🙂
how about using transparent proxy where the squid server is in the same machine, does it work too?
thanx….
thx 🙂
it wont work by default. theres some patches for squid to get that done.
mas ….. cara configurasinya kok ngak di jelaskann
kalo bisa ngikutin instalasi nya, saya yakin bisa konfigurasi sendiri 🙂 kan GUI, webbased, gampang lah itu
ya… makasihh maassss
mas saya alami dalam instalasinya.. waku saya buka di localhostnya .. keluar peringatan bahwa tidak diketemukan
“include_once=DB.php in dba.php”
mohon pencerahannya….
@diaz
sama aku jg dpet error itu, tp coba deh km install php-pear insyaAllah bisa
Untuk memakai banjar ini persyaratan mutlak pengetahuannya apa saja mas ?
Saya sudah menginstall nya tapi saya masih bgg cara pengaturannya….
Regards
Jefri
oya pak anti mysql drop itu, maksudnya mysql gak bisa keluar masuk ya pak… gimana dong kita meletakkan web conten yang ada mysql agar yang lain bisa terhubung dengan jaringan lainnya ?
oya mas config editing disabled by admin, cara idupin nya diedit dimana ya mas ?
wah baru dapat saya caranya hehehhe ternyata dirubah di config.php kekekkeek sori mas terlalu buru2 nanya btw masih blum bisa ni ngatur trafficknya padahal eth nya uda bener… try n error lagi ahh
oya pak cara memantau traffic bandwidth client nya gimana ? kok koneksi teman saya masih cepat2 aja pak…
pak, saya begitu menjalankan program ini malah internet saya mati…
dari segi config saya sudah benar downlink = eth0 and uplink = eth2 karena ke internet saya di eth2.
Apa ada pengaruh karena saya memakai modem usb ?
btw saya sudah memberi aturan ke ip mana aja. Kalau bapak mau melihat banjar.sh saya di http://rapidshare.com/files/134591910/banjar.sh.html
Terima Kasih….
NB : Maaf pak tadi saya comment ke banjar 0.2 sekarang saya memakai banjar 0.8
liat /etc/banjar/netfilter.masquerade
network anda kan 192.168.0.0/24 yah, ganti 192.168.1.0/24 ke 192.168.0.0
dan jangan di tulis ulang, cukup ganti aja 1.0 ke 0.0
(/sbin/iptables lalala… ini salah, yang bener $IPTABLES …..)
Sudah saya ubah seperti yang bapak bilang… ini kutipan netfilter.masquerade
”
# SNAT or masquerade clients
# use SNAT
# this is just an example, network address value and SNAT target must be changed according to your network setup
# if you dont use this rule, or you dont provide NAT then you must mark below line as commented
# $IPTABLES -t nat -A POSTROUTING -s 192.168.1.0/24 -j SNAT –to-source 123.123.123.123
# or MASQUERADE, pick one either SNAT or MASQUERADE
$IPTABLES -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE
# Failsave (only enabled when problems occured)
# $IPTABLES -t nat -I POSTROUTING -j MASQUERADE
”
and ini kutipan keseluruhan banjar.sh nya
http://rapidshare.com/files/134824762/banjar.sh.html
untuk bapak ketahui IP lokal saya 192.168.0.2 …..
Terima Kasih..
Maaf pak sebagai tambahan ini list iptables default saya sebelum banjar.sh dilaksanakan…
“”
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT all — anywhere anywhere
LOG all — 127.0.0.0/8 anywhere LOG level warning
DROP all — 127.0.0.0/8 anywhere
ACCEPT all — anywhere 255.255.255.255
ACCEPT all — 192.168.0.0/24 anywhere
ACCEPT !tcp — anywhere BASE-ADDRESS.MCAST.NET/4
LOG all — 192.168.0.0/24 anywhere LOG level warning
DROP all — 192.168.0.0/24 anywhere
ACCEPT all — anywhere 255.255.255.255
ACCEPT all — anywhere host-202-169-231-47.jogjamedianet.com
ACCEPT all — anywhere 202.169.231.255
DROP all — anywhere ALL-SYSTEMS.MCAST.NET
LOG all — anywhere anywhere LOG level warning
DROP all — anywhere anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
ACCEPT all — 192.168.0.0/24 anywhere
ACCEPT all — anywhere anywhere state RELATED,ESTABLISHED
LOG all — anywhere 192.168.0.0/24 LOG level warning
DROP all — anywhere 192.168.0.0/24
DROP all — anywhere ALL-SYSTEMS.MCAST.NET
LOG all — anywhere anywhere LOG level warning
DROP all — anywhere anywhere
Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT all — anywhere anywhere
ACCEPT all — anywhere 255.255.255.255
ACCEPT all — anywhere 192.168.0.0/24
ACCEPT !tcp — anywhere BASE-ADDRESS.MCAST.NET/4
LOG all — anywhere 192.168.0.0/24 LOG level warning
DROP all — anywhere 192.168.0.0/24
ACCEPT all — anywhere 255.255.255.255
ACCEPT all — host-202-169-231-47.jogjamedianet.com anywhere
ACCEPT all — 202.169.231.255 anywhere
DROP all — anywhere ALL-SYSTEMS.MCAST.NET
LOG all — anywhere anywhere LOG level warning
DROP all — anywhere anywhere
“”
saya sudah mencoba berulang kali tetap gak bisa pak.
saya curiga di iptables nya setelah memakai banjar efeknya saya gak bisa ngeping ke ISP bahkan saya tidak bisa ping network saya sendiri. Btw ini list iptables setelah memakai banjar pak.
”
burkass@BurkASS:~$ sudo iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
REJECT all — anywhere anywhere state INVALID reject-with icmp-port-unreachable
ACCEPT all — anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp — anywhere anywhere icmp echo-request length 0:100
DROP icmp — anywhere anywhere icmp echo-request
ACCEPT all — 192.168.0.77 anywhere
ACCEPT all — 192.168.0.7 anywhere
ACCEPT all — 192.168.0.17 anywhere
ACCEPT all — 192.168.0.77 anywhere
ACCEPT all — 192.168.0.7 anywhere
ACCEPT all — 192.168.0.17 anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
DROP tcp — anywhere anywhere tcp dpt:66
DROP udp — anywhere anywhere udp dpt:66
DROP tcp — anywhere anywhere tcp dpt:118
DROP udp — anywhere anywhere udp dpt:118
DROP tcp — anywhere anywhere tcp dpt:150
DROP udp — anywhere anywhere udp dpt:150
DROP tcp — anywhere anywhere tcp dpt:156
DROP udp — anywhere anywhere udp dpt:156
DROP tcp — anywhere anywhere tcp dpt:1114
DROP udp — anywhere anywhere udp dpt:1114
DROP tcp — anywhere anywhere tcp dpt:ms-sql-s
DROP udp — anywhere anywhere udp dpt:ms-sql-s
DROP tcp — anywhere anywhere tcp dpt:ms-sql-m
DROP udp — anywhere anywhere udp dpt:ms-sql-m
DROP tcp — anywhere anywhere tcp dpt:1498
DROP udp — anywhere anywhere udp dpt:1498
DROP tcp — anywhere anywhere tcp dpt:1978
DROP udp — anywhere anywhere udp dpt:1978
DROP tcp — anywhere anywhere tcp dpt:1979
DROP udp — anywhere anywhere udp dpt:1979
DROP tcp — anywhere anywhere tcp dpt:mysql
DROP udp — anywhere anywhere udp dpt:mysql
DROP tcp — anywhere anywhere tcp dpt:3352
DROP udp — anywhere anywhere udp dpt:3352
DROP tcp — anywhere anywhere tcp dpt:postgresql
DROP udp — anywhere anywhere udp dpt:postgresql
DROP icmp — anywhere anywhere length 92
ACCEPT all — 192.168.0.77 anywhere
ACCEPT all — 192.168.0.7 anywhere
ACCEPT all — 192.168.0.17 anywhere
ACCEPT all — 192.168.0.77 anywhere
ACCEPT all — 192.168.0.7 anywhere
ACCEPT all — 192.168.0.17 anywhere
DROP all — anywhere anywhere
Chain OUTPUT (policy DROP)
target prot opt source destination
“
kalo pake banjar semua konfig iptables harus dari banjar (biasanya kita ngedit netfilter.control nya aja kalo ada command2 yang custom)
biar ga ribet, kalo udah ngerti silakan modifikasi
rupanya sistem ini sebaiknya default iptablesnya accept ya pak 🙂 sekarang saya sudah bisa karena sebelumnya saya pake default drop pada iptables saya.
Pak Anton, kalau boleh saya nanya. Apakah rule iptables yang sebegitu banyak bagi router anda tidak berpengaruh pada packet forwarding?
Terus terang saya tidak menggunakan banjar. Saya membuat sendiri rule mangle iptables untuk memisahkan IIX dan intl (marking), serta menggunakan htb.init untuk shaping.
Koneksi internasional ter-shape dengan baik. Tapi koneksi IIX terpengaruh besar sekali gara2 rule yang sekitar 500-an baris. Bahkan tanpa htb pun, koneksi IIX jadi cukup pelan ketika rule mangle diterapkan?
Ada pencerahan mungkin? Terimakasih banyak.
hi banjar users, i’m trying to setup banjar for my network, i have followed everything in the instruction but when i browse banjar directory it don’t display anything. i’m also wondering why the file “banjar.db” is empty. is it supposed to be so?
another thing is the path of the database name in the banjar.php ($db_param[‘name’] = “/etc/banjar/banjar.db”; ) is this path correct? i’m using MySQL database.
any help will be appreciated
Pak,kalo instalasi di centos/fedora bagaimana? beda direktorinya…
Paket sqlite3 apa bisa di fedora/centos?
salam knal om anton.
btw setelah nyoba banjar kok beban di router agak berat yh apa karna terlalu banyak printah d iptablesnya ditambah lagi dengan service pendukung seperti apache dan mysql….
mohon pencerahannya om
thx before
Pingback: BANdwidth Justification for AdministratoR ver 0.81 » welcome to my box
Pingback: BANdwidth Justification for AdministratoR ver 0.81 - www.lanxic.web.id