Bandwidth Manajemen Menggunakan MasterShaper

From OnnoCenterWiki
Jump to: navigation, search

Kebutuhan

his is only a quick overview over MasterShaper's requirements. Check out the Documentation for detail informations.

Generic

   * Linux Kernel v2.4 or v2.6
   * Kernel support for QoS and/or fair queuing
   * Kernel support for Netfilter (iptables)
   * New versions of iptables (ex 1.2.11) and iproute2 (ex 20041019-3)
   * Perl
   * sudo (so webserver - mostly not running as root - can load the shaper rules which needs root privileges) 

Web Interface

   * Apache or Apache2 (httpd.apache.org)
   * PHP with libgd, jpeg and MySQL support
   * several PHP PEAR modules
   * MySQL
   * phplayersmenu
   * jpgraph 

IMQ - Intermediate Queueing Device

If you want to shape on a single interface:

   * Patched kernel 


Teknik Instalasi

 MasterShaper on "debian-40r1-i386-CD-1"

This guide is made by jessdk.

TIP: A lot of users have already try with "debian-40r2-i386-CD-1" and everything is still working perfectly ! ! !


THIS GUIDE IS A 100% CUT / PAST GUIDE - READ IT CAREFULLY - MASTERSHAPER IS WORKING WHEN YOU ARE FINISH

My guide is also in the MasterShaper Forum:

If you have try my guide then please write your result in my own post.

HERE: http://www.mastershaper.org/forum/index.php?topic=431.0

Thank you so much I hope to hear from you when you have try my guide !


Here comes my own private install guide.

It will take around 2 hours to install the Debian Server with MasterShaper on.

My own complete "howto install MasterShaper" on a 100 % fresh installed "debian-40r1-i386-CD-1"

Link to download Debian: http://www.debian.org/

Instruction for your Debian installation:

1. Under the installation of debian I just select a [X] standart install ( No web server, no desktop and so on ONLY standart install )

2. Important Note: REMEMBER to setup a network mirror under your Debian installation ! ! ! !

I have used this site as inspiration:

http://www.oneunified.net/blog/2006/11/05/

http://blog.chinaunix.net/u1/47765/showart_435719.html

Here is ALL my files that you make a "wget" to in my guide: I have made ONE big Zip file with all the files I have downloadet for to make the guide for you ! ! !

http://mastershaper.paerehaven.dk/ALL_MY_FILES_FROM_THIS_GUIDE.zip

Install ssh on your server so you can copy / past all this commands to a ssh telnet client

Now log on to your server as "root" user and now you type:

apt-get install ssh

Now you can log into your server via ssh.

For to log into your server via "ssh" then use ex. "Putty" For: Windows 95, 98, ME, NT, 2000, XP and Vista on Intel x86 Download Putty here: http://mastershaper.paerehaven.dk/putty-0.60-installer.exe

nano /etc/apt/sources.list

From:

deb cdrom:[Debian GNU/Linux 4.0 r1 _Etch_ - Official i386 CD Binary-1 2007081$

To:

  1. deb cdrom:[Debian GNU/Linux 4.0 r1 _Etch_ - Official i386 CD Binary-1 2007081$

TIP: Now you can take out your CD-ROM in your CD-ROM drive in your server.

apt-get update

apt-get upgrade (If there are any upgrade then say yes to install it)


apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 g++ g++-4.1 libstdc++6-4.1-dev yaird


cd /usr/src

wget http://mastershaper.paerehaven.dk/iptables-1.3.6.tar.bz2 wget http://mastershaper.paerehaven.dk/patch-o-matic-ng-20071128.tar.bz2 wget http://mastershaper.paerehaven.dk/linux-2.6.18.tar.bz2 wget http://mastershaper.paerehaven.dk/l7-protocols-2007-10-10.tar.gz wget http://mastershaper.paerehaven.dk/netfilter-layer7-v2.14.tar.gz

tar jxvf linux-2.6.18.tar.bz2 tar jxvf iptables-1.3.6.tar.bz2 tar jxvf patch-o-matic-ng-20071128.tar.bz2 tar zxvf netfilter-layer7-v2.14.tar.gz tar zxvf l7-protocols-2007-10-10.tar.gz

ln -s linux-2.6.18 linux ln -s iptables-1.3.6 iptables

cd /usr/src/patch-o-matic-ng-20071128

./runme --download

Her is the message you now will get:

Successfully downloaded external patch geoip

Successfully downloaded external patch condition

Successfully downloaded external patch IPMARK

Successfully downloaded external patch ROUTE

Successfully downloaded external patch connlimit

Successfully downloaded external patch ipp2p

Successfully downloaded external patch time

./patchlets/ipv4options exists and is not external

./patchlets/TARPIT exists and is not external

Successfully downloaded external patch ACCOUNT

Successfully downloaded external patch pknock

Hey! KERNEL_DIR is not set.

Where is your kernel source directory? [/usr/src/linux]

( Just - Press Enter - All is ok )

Hey! IPTABLES_DIR is not set.

Where is your iptables source code directory? [/usr/src/iptables]

( Here - Just Press Enter - All is ok )

Loading patchlet definitions......................... done

Excellent! Source trees are ready for compilation.

pwd /usr/src/new/patch-o-matic-ng-20071128

KERNEL_DIR=/usr/src/linux-2.6.18 IPTABLES_DIR=/usr/src/iptables-1.3.6 ./runme ROUTE KERNEL_DIR=/usr/src/linux-2.6.18 IPTABLES_DIR=/usr/src/iptables-1.3.6 ./runme ipp2p KERNEL_DIR=/usr/src/linux-2.6.18 IPTABLES_DIR=/usr/src/iptables-1.3.6 ./runme time

cd /usr/src/linux-2.6.18 patch -p1 < /usr/src/netfilter-layer7-v2.14/for_older_kernels/kernel-2.6.18-2.6.19-layer7-2.9.patch

cd /usr/src/iptables-1.3.6 patch -p1 < /usr/src/netfilter-layer7-v2.14/iptables-for-kernel-pre2.6.20-layer7-2.14.patch chmod +x /usr/src/iptables-1.3.6/extensions/.layer7-test

cd /usr/src/linux-2.6.18

make mrproper make menuconfig

Networking --->[*] Networking support [*] Networking options ---> [*] Network packet filtering (replaces ipchains) ---> [*] Network packet filtering (replaces ipchains) ---> IP: Netfilter Configuration ---> [M] Layer 7 match support (EXPERIMENTAL)

Networking --->[*] Networking support [*] Networking options ---> [*] Network packet filtering (replaces ipchains) ---> [*] Network packet filtering (replaces ipchains) ---> IP: Netfilter Configuration ---> <M> TIME match support

make-kpkg clean

make-kpkg --revision hbdebl7 --append-to-version .20071128 --initrd binary-arch

cd /usr/src/ ls

Now you can see this files... ( and some other files )

linux-image-2.6.18.20071128_hbdebl7_i386.deb

linux-headers-2.6.18.20071128_hbdebl7_i386.deb

dpkg -i linux-image-2.6.18.20071128_hbdebl7_i386.deb

nano /boot/grub/menu.lst

Set "Default 0" to the new kernel

( You do not need to change it Default 0 is the new kernel now )

Here we can see the old kernel

uname -a

Linux monitor 2.6.18-5-686 #1 SMP Fri Jun 1 00:47:00 UTC 2007 i686 GNU/Linux

reboot

Here we can see the new kernel

uname -a

Linux monitor 2.6.18.20071128 #1 SMP Sat Dec 15 21:43:09 CET 2007 i686 GNU/Linux

cd /usr/src/iptables-1.3.6 export KERNEL_DIR=/usr/src/linux-2.6.18 export IPTABLES_DIR=/usr/src/iptables-1.3.6 make make BINDIR=/usr/local/sbin LIBDIR=/usr/local/lib MANDIR=/usr/local/man make BINDIR=/usr/local/sbin LIBDIR=/usr/local/lib MANDIR=/usr/local/man install

cd /usr/src/l7-protocols-2007-10-10 make install

In this forum I have found "ipp2p-0.99.6-r2.tar.gz"

ShadowStar ipp2p - http://linux.chinaunix.net/bbs/thread-914377-1-1.html

Now I have uploadet this file to my own site - Just follow the rest of my guide........

cd /usr/src/ wget http://mastershaper.paerehaven.dk/ipp2p-0.99.6-r2.tar.gz tar zxvf ipp2p-0.99.6-r2.tar.gz

cd /usr/src/ipp2p-0.99.6-r2 make

cp libipt_ipp2p.so /usr/local/lib/iptables/ cp ipt_ipp2p.ko /lib/modules/2.6.18.20071128/

depmod -a modprobe ipt_ipp2p

Here I have found iptables-ipid-2.1.tar.tar-Just follow my guide

http://linux.chinaunix.net/bbs/thread-888274-1-2.html

http://linux.chinaunix.net/bbs/thread-909127-1-2.html

cd /usr/src/ wget http://mastershaper.paerehaven.dk/iptables-ipid-2.1.tar.tar tar xvf iptables-ipid-2.1.tar.tar

cd iptables-ipid-2.1 make

cp libipt_IPID.so /usr/local/lib/iptables/ cp ipt_IPID.ko /lib/modules/2.6.18.20071128/

depmod -a

modprobe ipt_IPID modinfo ipt_IPID

Her is what you get now:

monitor:/usr/src/iptables-ipid-2.1# modinfo ipt_IPID

filename: /lib/modules/2.6.18.20071128/ipt_IPID.ko

author: Ssffzz1 <ssffzz1@126.com>

description: IP tables IPID modification module

license: GPL

vermagic: 2.6.18.20071128 SMP mod_unload 686 REGPARM gcc-4.1

depends: x_tables

apt-get install mysql-server-4.1


mysql create database shaper; grant all privileges on shaper.* to 'shaper'@'localhost' identified by 'shaper' with grant option; exit


cd /usr/src

wget http://mastershaper.paerehaven.dk/mastershaper_0.44.tar.tar

tar -xjvf mastershaper_0.44.tar.tar

cd MasterShaper-0.44

apt-get install apache2

mkdir /var/www/shaper

cp -R htdocs/* /var/www/shaper/

chown -R www-data.www-data /var/www/shaper

cd /usr/src

apt-get install iproute sudo php4-pear php-db php4-mysql libphp-jpgraph libphp-phplayersmenu pear install DB Net_IPv4 cd /var/www/shaper ln -s /usr/share/php/libphp-phplayersmenu phplayersmenu ln -s /usr/share/jpgraph jpgraph

nano /etc/sudoers

Add this line in the bottom so MasterShaper can get root privileges

www-data ALL=NOPASSWD: /var/www/shaper/shaper_loader.sh

apt-get install libapache2-mod-php4

sudo a2enmod php4

apt-get install php4-mysql

Now we must downgrade to jpgraph-1.22 so we can use or monitor in the webinterface

cd /usr/src wget http://mastershaper.paerehaven.dk/jpgraph-1.22.tar.tar tar -zxvf jpgraph-1.22.tar.tar cd /usr/src/jpgraph-1.22/src/ cp /usr/src/jpgraph-1.22/src/*.* /usr/share/jpgraph/

nano /var/www/shaper/shaper_stats.php

Now change from this to this:

/* include jpgraph library require_once "jpgraph/src/jpgraph.php"; require_once "jpgraph/src/jpgraph_line.php"; require_once "jpgraph/src/jpgraph_pie.php"; require_once "jpgraph/src/jpgraph_pie3d.php"; require_once "jpgraph/src/jpgraph_bar.php";

  • /

require_once "/usr/share/jpgraph/jpgraph.php"; require_once "/usr/share/jpgraph/jpgraph_line.php"; require_once "/usr/share/jpgraph/jpgraph_pie.php"; require_once "/usr/share/jpgraph/jpgraph_pie3d.php"; require_once "/usr/share/jpgraph/jpgraph_bar.php";

/etc/init.d/apache2 stop

/etc/init.d/apache2 start

Usage Notes To get help on the IPP2P IPTables plugin:

iptables -m ipp2p --help To run the GUI:

http://localhost/shaper

On the first configuration screen, iptables should be set to '/usr/local/sbin/iptables'.

Now run the setup in the webinterface

AND NEXT REMBER TO SETUP A NEW USER IN THE WEBINTERFACE

Select MENU -> "Settings" -> "Users" -> "Create a new User"

REMENBER TO SELCECT "STATUS" TO "Enabled" now "SAVE"

NOW SELECT THE MENU "Setup" AND NOW YOU MUST SETUP DOWNLOAD / UPLOAD SPEED AND SO ON.....

Menu -> "Other" -> "Update L7 Protocols" Press Submit on the next scree.

Select MENU -> "Rules" -> "Load"

Select MENU -> "Overview"

Shaper Status is now "active"

cd /var/www/shaper

./tc_collector.pl -d

./tc_collector.pl -v3

Test Link jpgraph-2.2 + GD Here (Change your local IP in this link)

http://10.1.45.248/shaper/shaper_stats.php?show=chains&graphmode=0&showif=eth0&scalemode=kbit&uniqid=1164810657

Goto your webinterface and load your rules:

Select MENU -> "Rules" -> "Load"

cd /var/www/shaper

./tc_collector.pl -d

Congratulation now you have installed a MasterShaper

Now you MasterShaper is up and running.

IMPORTENT NOTE:

EVERY TIME YOU REBOOT YOUR SERVER THEN YOU NEED TO DO THIS:

cd /var/www/shaper

./tc_collector.pl -d

Goto your webinterface and load your rules:

Select MENU -> "Rules" -> "Load"

Now you MasterShaper is up and running.

IF NOT RUNNING NOW THEN RELOAD YOUR RULES AGAIN AND / OR DO THIS AGAIN:

cd /var/www/shaper

./tc_collector.pl -d

Goto your webinterface and load your rules:

Select MENU -> "Rules" -> "Load"

cd /var/www/shaper

./tc_collector.pl -v3

Now you can see all the data on ethx and ethx Bridge setup

As Bonus I have include a bride setup for your installation -- Bridge setup --

Follow my guide:

apt-get install bridge-utils

nano /etc/network/interfaces file

auto lo iface lo inet loopback

  1. auto eth2
  2. iface eth2 inet dhcp
  3. auto eth3
  4. iface eth3 inet dhcp

auto bridge01 iface bridge01 inet dhcp pre-up ifconfig eth0 down pre-up ifconfig eth1 down pre-up brctl addbr bridge01 pre-up brctl addif bridge01 eth0 pre-up brctl addif bridge01 eth1 pre-up ifconfig eth0 0.0.0.0 pre-up ifconfig eth1 0.0.0.0 post-down ifconfig eth0 down post-down ifconfig eth1 down post-down ifconfig bridge01 down post-down brctl delif bridge01 eth0 post-down brctl delif bridge01 eth1 post-down brctl delbr bridge01

/etc/init.d/networking restart

ifconfig

Now you can see the new bride - DONE

More good information about MasterShaper and Bridge can be found here:

http://www.mastershaper.org/index.php/MasterShaper_on_a_Linux-Bridge

/etc/init.d/apache2 stop

/etc/init.d/apache2 start

cd /var/www/shaper

./tc_collector.pl -d

Goto your webinterface and load your rules:

Select MENU -> "Rules" -> "Load"

Now you MasterShaper is up and running.

cd /var/www/shaper

./tc_collector.pl -v3 ( Press Ctrl + Z for to exit this again )


IMPORTEN:

Every time you reboot you server - then you must du this step here:

cd /var/www/shaper

./tc_collector.pl -d

Goto your webinterface and load your rules:

Select MENU -> "Rules" -> "Load"

Now you MasterShaper is up and running.

cd /var/www/shaper

./tc_collector.pl -v3 ( Press Ctrl + C for to exit this again )

And now you can see the data on your interfaces. Install Ntop Network Monitor 3.3

Install Ntop Network Monitor.

apt-get install rrdtool libpcap-dev graphviz librrd2-dev libtool apt-get install automake autoconf libgdbm-dev snmp openssl libcurl3-openssl-dev libpcap0.8-dev apt-get install gsfonts-x11

cd /usr/src/

wget http://mastershaper.paerehaven.dk/ntop-3.3.tar.tar

tar xzvf ntop-3.3.tar.tar

cd /usr/src/ntop-3.3

./autogen.sh ./configure make make install

NOTE: ntop can show traffic by AS (Autonomous System) Number

Because this feature consumes a number of MB of memory,

the datafile is not installed by default.

Which, if there is no file - from this or a previous

install - effectively disables the ASN feature.

To install the AS data, type:

  1. make install-data-as 

ls: /usr/local/lib/*ntop*.so: No such file or directory

ls: /usr/local/lib/*Plugin*.so: No such file or directory

WARNING: This install created a directory for the ntop

files and databases:

//usr/local/share/ntop

This directory MUST be owned by the user

which you are going to use to run ntop.

The command you must issue is something like:

chown -R ntop.ntop //usr/local/share/ntop

or

chown -R ntop:users //usr/local/share/ntop

man chown to check the syntax for YOUR system

ntop -A

Now set your administrator password

groupadd ntop

useradd -s /bin/false -d /usr/local/var/ntop -g ntop ntop

chown -R ntop:ntop //usr/local/var/ntop

cd /usr/src/

wget http://mastershaper.paerehaven.dk/rrdtool-1.2.26.tar.tar tar xvfz rrdtool-1.2.26.tar.tar

cd rrdtool-1.2.26

./configure

make make install

ntop -P /usr/local/var/ntop -u ntop -d

Now go to your favorit web browser:

http://localhost:3000/

Or

http://Here you type your ip adress on your server:3000/

Username and Password in your web interface is now:

Username: admin

Password: The password you have give it


And after every reboot you need to type this command every time for to start Ntop Monitor.

ntop -P /usr/local/var/ntop -u ntop -d

Now you are running

You can stop Ntop 100% in your Ntop webinterface.

A good idea is to use Ntop for a shoot time to monitor the traffic on your network.

Another good idea is to delete this folders - interfaces - graphics - flows - when you are finish your monitoring every day.

This folders will be restored next time you start up "Ntop" The folder - interfaces - is the folder with the biggest files.

Here is how to delete the folders:

rm -r /usr/local/var/ntop/rrd/interfaces/ rm -r /usr/local/var/ntop/rrd/graphics/ rm -r /usr/local/var/ntop/rrd/flows/

Here is a little tip: NTOP -> RRD <- can fill out your 40 GB HDD harddisk drive with data on 2 days if there is many P2P users on your network.

Then you can get in trouble with your system and your mysql server is not working anymore and so on.

I found a metod to free up my harddisk drive just delete this 3 folders " interfaces, graphics, flows " it take a lot of time to delete 35 GB data from a harddisk drive

rm -r /usr/local/var/ntop/rrd/interfaces/ rm -r /usr/local/var/ntop/rrd/graphics/ rm -r /usr/local/var/ntop/rrd/flows/

Now you will have a LOT of FREE SPACE again


MUNIN

As BONUS I also have made a howto install munin on this machine

Use this tip if you will see a lot of statistics on your server:

localhost.localdomain :: [ Disk Exim Mysql Network Processes System ] and so on it is a really nice tool.

apt-get install munin munin-node

/etc/init.d/munin-node restart


http://localhost/munin/

or

http://her is your IP on your server/munin/


Referensi

Pranala Menarik