See the content

Control of Banda uncomplicated with HTB Tools

Control posts in the series of Banda with HTB-Tools

  1. Control of Banda uncomplicated with HTB Tools
  2. HTB-Tools: practical examples of configuration

Originally published in http://wasare.net on 12/08/2006 and SlackwareZine Paragraph 9

  1. Introduction
  2. Installation
  3. Configuration
  4. Enabling the HTB
  5. Monitoring the Control of Banda

1. Introduction

The HTB (Hierarchical Token Bucket) is a good alternative to replace the cBq (Class Based Queueing) because it is more accurate and easy to use (will? For me it was). The difference for the cBq is that it allocates bandwidth to one or more classes ( "virtual links") and takes the band temporarily loaned to another class that is not being fully used. Also unlike the cBq you can allocate various clients in the same class. To use the HTB you need a kernel 2.4.20 or greater and tool tc (Traffic Control) package included in the package iproute2 being sought iproute2> = 2.6.10-ss050124. I used only the Slackware 10.2 (or kernel 2.4.31 Kernel 2.6.13) with the package iproute2-2.6.11_050330 (n series of Slackware) installed.

To configure the HTB we have basically three alternatives:

  • Create a script with all the commands (if you know what that is);
  • Using the utility htb.init script similar to cbq.init and that demands a variety of settings, and familiar to anyone who has used the cBq, or
  • Using the tool HTB Tools. How to simplify and I have no experience with the cBq opted by HTB Tools created within the philosophy of Slackware.

Download the HTB-tools-0.2.7.tar.gz at: http://htb-tools.arny.ro/download.php

If you do not like to manually install and want to skip the setup package in the download format. Tgz on the same link above or at: http://www.linuxpackages.net/pkg_details.php?id=8121

Unzip the package with the sources and run:

  root @ ice: ~ # cd HTB-tools-0.2.7, make, make install 

To complete the installation, run the following commands:

  HTB-tools-0.2.7 # mkdir -p /etc/htb root @ ice: ~ / HTB-tools-0.2.7 # mkdir-p / etc / HTB 
  HTB-tools-0.2.7 # cp sys/scripts/rc.htb /etc/rc.d/rc.htb root @ ice: ~ / HTB-tools-0.2.7 sys # cp / scripts / rc.htb / etc / rc.d / rc.htb 
  HTB-tools-0.2.7 # cp sys/cfg/eth0-qos.cfg /etc/htb/eth0-qos.cfg root @ ice: ~ / HTB-tools-0.2.7 # cp sys/cfg/eth0-qos.cfg / etc/htb/eth0-qos.cfg 
  HTB-tools-0.2.7 # cp sys/cfg/eth1-qos.cfg /etc/htb/eth1-qos.cfg root @ ice: ~ / HTB-tools-0.2.7 # cp sys/cfg/eth1-qos.cfg / etc/htb/eth1-qos.cfg 

Above copy the configuration files as an example for the interfaces eth0 and eth1 and start up script rc.htb.

For the format. Tgz, run only:

  root @ ice: ~ # HTB-installpkg tools-0.2.7-i486-1wsa.tgz 

3. Configuration

HTB Tools installed its SuSE will have the executable:

  • q_parser - reads the configuration file where clients, the
    classes, and the allocated band is defined and generates a script as
    settings established;
  • q_show - displays real-time bandwidth used / allocated to each
    Class / client by configuration;
  • q_checkcfg - check the syntax of the configuration file;
  • HTB - script that executes routines with the binary q_show,
    q_parser, q_checkcfg;
  • htbgen - utility to generate configuration files for
    Classes networks C.

The configuration files are in / etc / HTB. Using Tools HTB we simplify the configuration and tracking of allocation bandwidth for both upload and download.

The large balcony of the creator of the HTB Tools was set a configuration similar to the file named.conf (who never gave a glance?). Let the example: you have a link to 512kpbs shared between two clients, each theoretically should have guaranteed 256kpbs (QoS), however you let the thing loose and a customer starts to complain that the link is very slow and it can not perform major transactions. No need to say anything else, the other client is "abusing" the link. The fault is not his, since you left, do you? To solve this problem we will in fact distribute the link as follows: each client will have guaranteed 192kpbs and up to 256kps upload / download.

Assuming that your LAN interface is eth0 we will monitor the upload / download the file creating / etc/htb/eth0-qos.cfg with the following contents:

  Wireless class ( 
                bandwidth 480; 
                limit 512; 
                burst 2; 
                priority 1; 

               (Client cliente_1 
                    bandwidth 192; 
                    limit 256; 
                    burst 2; 
                    priority 1; 
                    24 ; } ; (192.168.1.2 src / 24;); 
                    24 ; } ; dst (192.168.1.2 / 24;); 
               ); 

             (Client cliente_2 
                    bandwidth 192; 
                    limit 256; 
                    burst 2; 
                    priority 1; 
                    24 ; } ; src (192.168.2.2 / 24;); 
                    24 ; } ; dst (192.168.2.2 / 24;); 
              ); 

  ); 

  ; } ; (Class default bandwidth 8;); 

As we can see the setup is self explanatory. But not to leave doubts that the src can see, how should we suspect, is the source or the source of traffic, for reasons we limit the output (upload). In the case of the policy dst control the destiny or the entry (download). The basic structure can be summarized in a main class that is subdivided into other secondary classes. When there is more of a main class they do not share bandwidth between them. The secondary classes (customers) can share bandwidth between them by configuration (limit higher). Each class has a primary or secondary classes more (customers). The special class specifies a default bandwidth for other customers / trades that are not included in the configuration. The transfer rate and given in kbit per second (kpbs).

To control the download / upload in eth1 simply create a file similar to / etc/htb/eth0-qos.cfg in / etc/htb/eth1-qos.cfg assuming that its interface eth1 is the other LAN or the WAN. In / etc/htb/eth1-qos.cfg create the main class and the class customers as necessary.

In more complex settings you can specify multiple IP's or networks (network / mask) within the same class secondary among the keys to the src or dst, when a (a) per line and finalized by a semi-colon. Now if you want to limit the band for a particular service for example ftp or http give a space and place the door of the service (in src or dst), thus:

 ... 

  Dst ( 
           ; 192.168.3.0 / 24 21; 
           ; 192.168.4.0 / 24 80; 
  ); 

  ... 

Warning: be careful when creating the classes will be limited because all traffic for that client / ip for all protocols. Combine various classes and settings until you reach the ideal control.

Before enabling the control of bandwidth is advisable to check the syntax of the configuration:

  root @ ice: ~ # q_checkcfg / etc/htb/eth0-qos.cfg 
  root @ ice: ~ # q_checkcfg / etc/htb/eth1-qos.cfg 

4. Enabling the HTB

To facilitate things make the rc.htb executable:

  root @ ice: ~ # chmod + x / etc / rc.d / rc.htb 

With this script does not need to run directly from the binaries
HTB Tools. To enable the HTB for eth0 performing within
/ etc / rc.d:

  etc / rc.d # ./rc.htb start_eth0 root @ ice: / etc / rc.d #. / rc.htb start_eth0 

Do the same for eth1 obviously doing the necessary replacement of eth0 by eth1. If you have more than two interfaces change the rc.htb according to their needs. As we look to correct everything that the HTB is activated every boot, adding the above commands rc.local or another start up script of your choice.

Example:

  etc / rc.d # echo "/etc/rc.d/rc.htb start_eth0" >> /etc/rc.d/rc.local root @ ice: / etc / rc.d # echo "/ etc / rc.d / rc.htb start_eth0">> / etc / rc.d / rc.local 
  etc / rc.d # echo "/etc/rc.d/rc.htb start_eth1" >> /etc/rc.d/rc.local root @ ice: / etc / rc.d # echo "/ etc / rc.d / rc.htb start_eth1">> / etc / rc.d / rc.local 

5. Monitoring the Control of Banda

Initiated the HTB, you can monitor the use of the link in real time to track each customer individually uploading or downloading,
respectively, follow:

  etc / rc.d # ./rc.htb show_eth0 root @ ice: / etc / rc.d #. / rc.htb show_eth0 
  etc / rc.d # ./rc.htb show_eth1 root @ ice: / etc / rc.d #. / rc.htb show_eth1 

Take a look at HTB Tools package and you can still make use of htbgen utility to generate the configuration file via wizard and have a way to monitor the use of the web band (q_show.php). It is soft or what!

I hope you can uncomplicate control of the band with HTB Tools as well as I did.



BuscaPé, leader compared to prices in Latin America

Also read:

Submit a Comment

Your email will never be published or disclosed to third parties. Required fields are marked *