You are on page 1of 7

Bandwidth management menggunakan WebHTB, Squid

ZPH, mangle TOS iptables di Ubuntu Server 8.04

Setelah surfing di forum-forum akhirnya saya temukan management bandwidth berbasis web
yaitu WebHTB pengembangan dari HTB Tool. WebHTB dapat memaksimalkan bandwidth
yang kita peroleh dari ISP. Dalam kasus ini saya menggunakan Speedy paket unlimited 1Mbps
untuk 15 client.
Langkah-langkah untuk instalasi :
1. Instalasi Squid versi 2.7 STABLE3 atau yang terbaru dan support ZPH.
• Tambahkan repo main untuk intrepid pada file /etc/apt/source.list pada baris terakhir
admin@proxy:~$sudo nano /etc/apt/source.list
deb http://kambing.ui.ac.id/ubuntu intrepid main
atau menggunakan repo yang lainnya
deb http://id.archive.ubuntu.com/ubuntu/ intrepid main
kemudian update source list anda dan install squidnya
admin@proxy:~$sudo apt-get update
admin@proxy:~$sudo apt-get install squid squid-client squid-cgi
saat ini Squid telah terinstall dan berjalan dengan baik.
2. Konfigurasi Squid.
• Sebelumnya kita matikan service squid yang sedang berjalan
admin@proxy:~$sudo /etc/init.d/squid stop
yang paling penting adalah cara menandai paket-paket yang ada di mesin proxy
( CacheHIT ), yang memungkinkan implementasi ZPH ( Zero Penalty Hit )

konfigurasi squid.conf nya


http_port 3128 transparent
hierarchy_stoplist cgi-bin ? .js .jsp
acl QUERY urlpath_regex cgi-bin \? .js .jsp
cache deny QUERY
cache_mem 32 MB
cache_swap_low 98
cache_swap_high 99
max_filedesc 8192
maximum_object_size 32 MB
minimum_object_size 0 KB
maximum_object_size_in_memory 512 bytes
ipcache_size 4096
ipcache_low 98
ipcache_high 99
cache_replacement_policy heap LFUDA
memory_replacement_policy heap GDSF
cache_dir aufs /cache 16000 16 256
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log none
pid_filename /var/run/squid.pid
dns_nameservers 202.134.2.5 203.130.196.155
cache_swap_log /var/log/squid/swap.state
emulate_httpd_log on
hosts_file /etc/hosts
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i \.(gif|png|jpg|jpeg|ico)$ 10080 90% 43200 override-expire
ignore-no-cache ignore-private
refresh_pattern -i \.(iso|avi|wav|mp3|mp4|mpeg|mpg|swf|flv|x-flv)$ 43200 90%
432000 override-expire ignore-no-cache ignore-private
refresh_pattern -i \.(deb|rpm|exe|zip|tar|tgz|ram|rar|bin|pdf|ppt|doc|tiff)$ 10080
90% 43200 override-expire ignore-no-cache ignore-private
refresh_pattern -i \.index.(html|htm|php|asp|aspx)$ 0 40% 10080
refresh_pattern -i \.(html|htm|css|js) 1440 40% 40320
refresh_pattern . 0 40% 40320
negative_ttl 1 minutes
half_closed_clients off
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563 # https, snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
snmp_port 3401
acl snmpsquid snmp_community public
snmp_access allow snmpsquid localhost
snmp_access deny all
acl lokal-net src 192.168.2.0/24 ## Sesuaikan
http_access allow lokal-net
http_access deny all
http_reply_access allow all
icp_access deny all
always_direct deny all
cache_mgr admin@lokal.net
visible_hostname proxy.lokal.net
cache_effective_user proxy
cache_effective_group proxy
coredump_dir /var/spool/squid
shutdown_lifetime 10 seconds
logfile_rotate 5
#Marking ZPH
zph_mode tos
zph_local 0×04
zph_parent 0
zph_option 136

Type Of Service (TOS) yang diberikan ke objek yang tercache menggunakan kode
mnemonic TOS Maximize-Reliability ( 0x04 ) untuk di MARK di iptables. Iptables yang
belum dipatch hanya mengenali 5 jenis Type Of Service ( TOS ) yaitu :
Normal-Service 0x00
Minimize-Cost 0x02
Maximize-Reliability 0x04
Maximize-Throughput 0x08
Minimize-Delay 0x10
lokasi cache saya pisahkan pada partisi yang berbeda pada 1 harddisk dan di mount pada
1 direktori /cache dengan ukuran 16GB menggunakan ReiserFS sebagai File Systemnya,
dalam beberapa forum dijelaskan ReiserFS lebih cepat pembacaan filenya daripada File
System EXT3.
Pastikan direktori tersebut dimiliki oleh user & group yang menjalankan squid.
admin@proxy:~$sudo chown -R proxy.proxy /cache
kemudian buat direktor swap
admin@proxy:~$sudo squid -z
apabila tidak ada pesan error, jalankan squidnya
admin@proxy:~$sudo /etc/init.d/squid start
Sampai disini anda telah berhasil memisahkan objek HIT dan MISS dengan ZPH mode
TOS.
3. MARK iptables untuk TOS ZPH
• Tandai paket dengan Type Of Service 0x04 pada mangle iptables TOS 0x04 dengan
MARK id 4.
admin@proxy:~$sudo iptables -A OUTPUT -t mangle -m tos --tos 0x04 -j MARK --set-
mark 0x04
Jangan lupa untuk menambahkan rules NAT/MASQUERADE dan REDIRECT HTTP ke
port squid serta firewall lainnya
Untuk NAT/MASQUERADE dan REDIRECT HTTP nya sebagai berikut :
admin@proxy:~$sudo iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j
MASQUERADE
admin@proxy:~$sudo iptables -t nat -A PREROUTING -p tcp -s 192.168.2.0/24
--dport 80 -j REDIRECT --to-ports 3128

kemudian save iptablesnya


admin@proxy:~$sudo iptables-save /lokasi-file-config-iptables

Istirahat sebentar sambil minum kopi dan menghisap Djarum Black Slimz
4. Instalasi WebHTB dan Apache2 support SSL.
• Diasumsikan Apache2, MySQL, dan php5 telah terinstall dan berjalan dengan baik.
Update Apache2 dan php5 dengan Apache2 dan php5 untuk intrepid.
admin@proxy:~$sudo apt-get install apache2 php5 php5-cli php5-mysql php5-snmp
php5-xmlrpc
Setelah selesai instalasi disable extra source list tadi dengan memberi tanda # di awal
baris
admin@proxy:~$sudo nano /etc/apt/source.list
#deb http://kambing.ui.ac.id/ubuntu intrepid main
atau
#deb http://id.archive.ubuntu.com/ubuntu/ intrepid main
kemudian update lagi source list anda, agar repo Ibex tidak diaktifkan.
admin@proxy:~$sudo apt-get update
Download source WebHTB di
http://biznetnetworks.dl.sourceforge.net/project/webhtb/WebHTB
V2.xx/WebHTB_V2.9/WebHTB_V2.9.bz2
Ekstrak ke folder /usr/local
admin@proxy:~$sudo tar -xjvf WebHTB_V2.9.bz2 -C /usr/local
Aktifkan module SSL Apache2
admin@proxy:~$sudo a2enmod ssl
Generate SSL key untuk apache2
admin@proxy:~$sudo apt-get install openssl ssl-cert
admin@proxy:~$sudo mkdir -p /etc/apache2/ssl
admin@proxy:~$sudo make-ssl-cert /usr/share/ssl-cert/ssleay.cnf
/etc/apache2/ssl/apache.pem
Buat Virtual Host Untuk Webhtb
admin@proxy:~$sudo nano /etc/apache2/sites-available/webhtb

Masukkan konfigurasi virtual hostnya


○ NameVirtualHost *:443 <virtualhost *:443>
 SSLEngine On SSLCertificateFile /etc/apache2/ssl/apache.pem
ServerAdmin admin@lokal.net DocumentRoot /usr/local/webhtb/
<directory />
 Options FollowSymLinks AllowOverride All
</directory> <directory "/usr/local/webthb">
 Options Indexes FollowSymLinks MultiViews AllowOverride All
Order allow,deny allow from all
</directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <directory "/usr/lib/cgi-bin">
 AllowOverride None Options +ExecCGI -MultiViews
+SymLinksIfOwnerMatch Order allow,deny Allow from all
</directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit, # alert,
emerg. LogLevel warn
CustomLog /var/log/apache2/access.log combined ServerSignature On
○ </virtualhost>
Aktifkan Virtual Host WebHTB
admin@proxy:~$sudo a2ensite webhtb
Reload konfigurasi apache anda
admin@proxy:~$sudo /etc/init.d/apache2 force-reload
Copy startup wehbtb
admin@proxy:~$sudo cp /usr/local/webhtb/docs/webhtb /etc/init.d
Set executable
admin@proxy:~$sudo chmod u+x /etc/init.d/webhtb
agar WebHTB start otomatis saat startup, jalankan perintah
admin@proxy:~$sudo invoke-rc.d webhtb start
Akses WebHTB anda dikomputer lain. Ketikkan pada address bar
https://lokasi-ip-webhtb-anda/setup/index.php
Masukkan :
MySQL admin user: root
MySQL admin password: (password root MySQL ada)
MySQL WebHTB user:
MySQL WebHTB password:
MySQL WebHTB password again:
MySQL WebHTB databasename: webhtb
Default interface: eth1 <--- Sesuaikan dengan interface LAN yang menuju ke
Lokalnet
Apabila tidak ada pesan error, WebHTB seharusnya berjalan dengan baik
WebHTB siap diakses melalui browser dengan address :
https://lokasi-ip-webhtb-anda/
5. Setup WebHTB
• Sebelum mensetup WebHTB sebaiknya anda set dulu password untuk user root, karena
password user root pada Ubuntu belum tersetup. Caranya adalah :
admin@proxy:~$sudo passwd root
Enter new UNIX password: ( isikan password untuk user root )
Retype new UNIX password: ( isikan lagi passwordnya )
passwd: password update successfully
Password untuk user root telah tersetup.
Sekarang kita hitung alokasi bandwidth yang didapat dari ISP, kemudian dibagi ke
client-client. Misalnya alokasi bandwidth yang didapat dari Speedy rata2 900Kbps.
Jumlal client 15 dan jatah bandwidth untuk masing-masing client 64Kbps limit 256Kbps.
Langkah-langkah pembagiannya sebagai berikut :
○ Pilih Interfaces -> Klik Add Interface Pilih interface yang mengarah ke jaringan
lokal ( dalam kasus ini eth1 ) lalu klik tulisan Click to add
○ Pilih Classes -> Klik Add Classes Isikan seperti dibawah ini :
 Name: Proxy-DNS Bandwidth: 10240 Limit: 10240 Burst: 0 Priority: 0
Que: SFQ Klik tombol gambar centang untuk menyimpan
 Name: Administrator Bandwidth: 1024 Limit: 1024 Burst: 0 Priority: 1
Que: SFQ Klik tombol gambar centang untuk menyimpan
 Name: Client-Net Bandwidth: 640 Limit: 900 Burst: 0 Priority: 2 Que:
SFQ Klik tombol gambar centang untuk menyimpan
○ Klik Add Clent Pilih pada drop down menu Class: Proxy-DNS Isikan seperti
dibawah ini :
 Client: CacheHIT Bandwidth: 10240 Limit: 10240 Burst: 32 Priority: 1
Mark: 4 ( sesuai dengan mangle MARK iptables ) Klik tulisan SAVE
untuk menyimpan
 Client: DNS-Rekues Bandwidth: 128 Limit: 128 Burst: 0 Priority: 1 SRC
IPS: IP DNS Server Lokal/Provider ( untuk mengisikan lebh dari satu IP
klik tulisan Click here for new src, dst .. SAVE
Pilih Class: Administrator Isikan seperti dibawah ini :
 Client: Admin-Gateway Bandwidth: 1024 Limit: 1024 Burst: 0 Priority: 2
SRC IPS: IP gateway DST IPS: IP Komputer Admin SAVE
 Client: Admin-Internet Bandwidth: 64 Limit: 256 Burst: 0 Priority: 3 SRC
IPS: kosongkan DST IPS: IP Komputer Admin SAVE
Pilih Class: Client-Net Isikan seperti dibawah ini :
 Client: Client-1 Bandwidth: 64 Limit: 256 Burst: 0 Priority: 3 SRC IPS:
kosongkan DST IPS: IP Komputer Client 1 SAVE
 Client: Client-2 Bandwidth: 64 Limit: 256 Burst: 0 Priority: 3 SRC IPS:
kosongkan DST IPS: IP Komputer Client 2 SAVE
dan seterusnya
Untuk mengaktifkan management bandwidthnya pilih Change QOS Status -> Klik
Start/Restart QOS.
Setiap melakukan perubahan/penambahan, harus dilakukan Restart QOS agar
perubahan/peambahan ditetapkan
Untuk melihat hasilnya bisa pilih Show -> Klik Show traffic
Management Bandwidth telah terinstall dan tersetup, setiap client mendapatkan jatah
bandwidthya masing-masing. Setelah itu anda hanya tinggal memantau bandwidth sambil
menghabiskan kopi hangat beserta Djarum Black anda he...he...he...

You might also like