OpenBSD


untuk para juragan yang punya warnet yang pake koneksinya lewat speedy di sini akan saya berikan sedikit tips dan trik supaya… low cost hight performance…

1). Alangkah baiknya jika.. anda tidak men-dial langsung lewat modem… tetapi menggunakan router (pengalaman saya pribadi dalam setahun saya sudah membeli sekitar 3 bh modem) selain *jare wong dermayue sih di awet-awet* kita juga bisa melakukan sedikit penghematan bandwith dengan tunning di squid sehingga… bikin koneksi joss 24jam full….

Oh iya… disini saya hanya akan menjelaskan… cara dial & tunning Squid pake OpenBSD OS sebagai router “kenapa tidak menggunakan mikrotik OS??” karena mikrotik OS berlisensi perlevel alias tidak gratis!!!

Lanjut ya…
1. Editlah ppp.conf nya

Kode:
# /etc/ppp/ppp.conf
default:
        set log Phase Chat LCP IPCP CCP tun command
        set redial 15 0
        set reconnect 15 10000
pppoe0:
        set device "!/usr/sbin/pppoe -i sk0"
        disable acfcomp protocomp
        deny acfcomp
        set mtu max 1492
        set mru max 1492
        set crtscts off
        set speed sync
        enable lqr
        set lqrperiod 5
        set cd 5
        set dial
        set login
        set timeout 0
        set authname userlogin@telkom.net
        set authkey passyangdikasihadminspeedy
        add! default HISADDR
        enable dns
        enable mssfixup

2. forward  /etc/sysctl.conf

Kode:
net.inet.ip.forwarding=1

aktifkan pf nya di /etc/rc.conf

Kode:
pf enable=YES

3. dial koneksinya

Kode:
# ppp -ddial pppoe0

4. jika berhasil terkoneksi maka openBSd akan membinding otomatis

Kode:
tun0: flags=8051 mtu 1492
        groups: tun egress
        inet 125.xxx.xxx.7 --> 125.163.72.1 netmask 0xffffffff

5. buatlah rules di firewallnya
#edit /etc/pf.conf

Kode:
lan_net = "192.168.1.0/24"
int_if  = "xl0"
ext_if = "tun0"
# scrub all
scrub in all
#  nat outgoing connections on each internet interface
nat on $ext_if from $lan_net to any -> ($ext_if)

6. agar openbsd mendial secara otomasti pada saat startup aktifkan di /etc/rc.local

Kode:
# aktifkan speedy
ppp -ddial pppoe0

Oke… anda sekarang sudah cukup menghemat cost dan membuat awet modem anda, sampai disini ada pertanyaan??? kalo tidak ada kita lanjut ke proses tunning Squid 2.7 stable 4. Kenapa menggunakan squid 2.7?? karena squid 2.7-stable4 adalah fungsi zph yang sudah terintegrasi.
ZPH sendiri adalah Zero Penalty Hit, penjelasan-nya bisa dibaca di http://zph.bratcheda.org/ (http://zph.bratcheda.org/) dan bisa menyimpan mencache Youtube (streaming dan lain2)

1. unduhlah paket Squid2.7 stable 4 (atau bisa juga STABLE 4 keatas)
2. Extraklah di sembarang tempat
3. configlah Squidnya…

Kode:
./configure \
--sysconfdir=/etc/squid \
--prefix=/usr \
--enable-async-io \
--enable-removal-policies=lru,heap \
--disable-delay-pools \
--disable-wccp \
--disable-wccp2 \
--enable-kill-parent-hack \
--enable-snmp \
--enable-default-err-languages=English --enable-err-languages=English \
--enable-linux-netfilter \
--disable-auth

4. lalu di

Kode:
#make

( dudu di mek-mek kaya apa bae.. :P )
5. terus di

Kode:
#make install

( dudu di mek terus di install :P )
6. Pada squid.conf masukan dibawah ini adalah hasil parsing td

Kode:
acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl localnet src 10.0.0.0/8	# RFC1918 possible internal network
acl localnet src 172.16.0.0/12	# RFC1918 possible internal network
acl localnet src 192.168.1.0/24	# RFC1918 possible internal network
acl SSL_ports port 443
acl Safe_ports port 80		# http
acl Safe_ports port 21		# ftp
acl Safe_ports port 443		# https
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 CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access deny all
icp_access allow localnet
icp_access deny all
http_port 3128 transparent
hierarchy_stoplist cgi-bin ?
cache_mem 6 MB
maximum_object_size_in_memory 32 KB
memory_replacement_policy heap GDSF
cache_replacement_policy heap LFUDA
cache_dir aufs /nfs/cache 20000 16 256
maximum_object_size 64 MB
cache_swap_low 98
cache_swap_high 99
access_log /var/log/squid/access.log squid
cache_log /var/log/squid/cache.log
cache_store_log none
log_fqdn off
storeurl_rewrite_program /etc/squid/store_url_rewrite
acl store_rewrite_list url_regex ^http://(.*?)/get_video\?
acl store_rewrite_list url_regex ^http://(.*?)/videodownload\?
storeurl_access allow store_rewrite_list
storeurl_access deny all
cache allow store_rewrite_list
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY
refresh_pattern ^http://(.*?)/get_video\? 10080 90% 999999 override-expire ignore-no-cache ignore-private
refresh_pattern ^http://(.*?)/videodownload\? 10080 90% 999999 override-expire ignore-no-cache ignore-private
refresh_pattern ^ftp:		1440	20%	10080
refresh_pattern ^gopher:	1440	0%	1440
refresh_pattern -i (/cgi-bin/|\?) 0	0%	0
refresh_pattern .		0	20%	4320
quick_abort_min 0
quick_abort_max 0
quick_abort_pct 98
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
vary_ignore_expire on
cache_effective_user squid
cache_effective_group squid
log_icp_queries off
ipcache_size 2048
ipcache_low 98
ipcache_high 99
memory_pools off
reload_into_ims on
coredump_dir /usr/var/cache
pipeline_prefetch on

7.kalo sudah bikin swap cache dan jalankan squidnya

Kode:
/sbin/squid -z
Kode:
/sbin/squid -D

8.Aktifkan pada saat startup

Kode:
/sbin/squid -sYD

9.Sisipkan redirect pada /etc/pf.conf, yang fungsinya meredirect protocol TCP dr locallan menuju squid
rdr on $lnt_if  proto tcp from any to any port 80 -> 192.168.1.1 port 3128

selesai…. kalo belum berhasil… silahkan kirim messeg ke saya yah…  ;)

source:  http://www.indramayucc.org

Bagaimana menggabungkan 2 line speedy dalam 1 LAN? Udah disiapin 1 komputer buat router dengan spek P4 dual core, ram 512Mb (sebenernya masih kurang untuk proxy server), HD 80G Sata, Lan Card 2 + 1 Onboard.
Nah tadinya rencananya sih mau pake mikrotik, eh malah dikasih HD SATA. Secara mikrotik 2.9.27 kan belum bisa pake SATA. Berbekal dari artikel itu akhirnya aku gunakan OpenBSD.
1. Install OpenBSD
Partisi HD 80G
5G /
1G swap
40G /cache #untuk cache squid proxy
10G /usr
10G /var
5G /tmp
sisa /home

Set instalasi
[X] bsd
[X] bsd.rd
[X] bsd.mp
[X] base41.tgz
[X] etc41.tgz
[X] misc41.tgz
[X] comp41.tgz
[X] man41.tgz
Disini aku menyertakan set bsd.mp karena menggunakan multi processor (p4 dual core).

selesai, reboot. kemudian mount cd openBSD untuk mengcopy source dan paket yang akan digunakan untuk mengcompile kernel kelak.
#mount /dev/cd0a /mnt
#tar -zxvf /mnt/packages/src.tar.gz -C /usr/src
#tar -zxvf /mnt/packages/sys.tar.gz -C /usr/src
#pkg_add -v /mnt/packages/dmassage-0.6.tgz #untuk menyesuaikan kernel dengan dmesg saat compile.
#pkg_add -v /mnt/packages/nano-2.0.3.tgz #text editor
#pkg_add -v /mnt/packages/ifstat-1.1p0.tgz
#pkg_add -v /mnt/packages/nmap-4.11p1.tgz
#pkg_add -v /mnt/packages/oidentd-2.0.7p1.tgz
#pkg_add -v /mnt/packages/pfstat-2.2p0.tgz
#pkg_add -v /mnt/packages/pftop-0.5.tgz

Catatan: Paket-paket yang diinstal sesuaikan dengan kebutuhan. Juga dapat diinstal melalui Port.

2. Compile Kernel
#cd /usr/src/sys/arch/i386/conf
#dmassage -s GENERIC >SKYNET
#nano -w SKYNET
tinggal sesuaikan sesuai hardware kita
tambahkan option berikut untuk optimasi squid diskd
option BUFCACHEPERCENT=15
option MSGMNB=16384
option MSGMNI=60
option MSGSEG=4096
option MSGSSZ=64
option MSGTQL=1024

kemudian keluar dan save.
#config SKYNET
#cd ../compile/SKYNET
#make clean && make depend && make
#rm -rf /usr/obj/*
#cd /usr/src
#make obj
#cd /usr/src/etc && env DESTDIR=/ make distrib-dirs
#cd /usr/src
#make build
tinggal tidur dulu, biasanya memakan waktu 3 jam.
setelah selesai kita ganti kernel kita
#cp /bsd /bsd.bak
#cp /usr/src/sys/arch/i386/compile/SKYNET/bsd /bsd
#reboot
untuk mengecek gunakan
#uname -a
harusnya kernel GENERIC sudah berubah menjadi SKYNET

3. Konfigurasi
Saya menggunakan konfigurasi sesuai artikelnya mas Yulian. Tinggal disesuaikan interface dan IP addressnya.
a. Aktifkan forwarding di /etc/sysctl.conf

net.inet.ip.forwarding=1
atau dengan
sysctl -w net.inet.ip.forwarding=1

b. Pastikan konfigurasi interface dan default routing kosong, hanya filename saja
Disini saya menggunakan card dari realtek
# /etc/hosts.rl0
# /etc/hosts.rl1
# /etc/hostname.rl0
# /etc/hostname.rl1
# /etc/mygate

Konfigurasi ethernet local /rl2
#touch /etc/hostname.rl2
#nano -w /etc/hostname.rl2
inet 192.168.1.100 255.255.255.0 NONE
media 100baseTX mediaopt full-duplex
description “ke LAN dan Gateway client”

Script koneksi DSL Speedy, pppoe0 untuk koneksi pertama dan pppoe1 untuk koneksi kedua. Sesuaikan interface, username dan passwordnya. Jangan lupa, gunakan indent tab.

# mv /etc/ppp/ppp.conf /etc/ppp/ppp.conf.bak
#touch /etc/ppp/ppp.conf
#nano -w /etc/ppp/ppp.conf
isi dengan=
default:
set log Phase Chat LCP IPCP CCP tun command
set redial 15 0
set reconnect 15 10000
pppoe0:
set device “!/usr/sbin/pppoe -i rl0?
disable acfcomp protocomp
deny acfcomp
set mtu max 1492
set mru max 1492
set crtscts off
set speed sync
enable lqr
set lqrperiod 5
set cd 5
set dial
set login
set timeout 0
set authname blahblahblah@telkom.net #nama
set authkey asaljangandejek #password
add! default HISADDR
enable dns
enable mssfixup
pppoe1:
set device “!/usr/sbin/pppoe -i rl1?
disable acfcomp protocomp
deny acfcomp
set mtu max 1492
set mru max 1492
set crtscts off
set speed sync
enable lqr
set lqrperiod 5
set cd 5
set dial
set login
set timeout 0
set authname blahblahblah2@telkom.net
set authkey vikingboneksamasaja
add! default HISADDR
enable dns
enable mssfixup

c. Aktifkan interface rl0 dan rl1

# ifconfig rl0 up
# ifconfig rl1 up

d. Jalankan PPPoE, Point to Point Protocol over Ethernet.

# ppp -ddial pppoe0
# ppp -ddial pppoe1

e. Jika koneksi Speedy berhasil, IP address dari Speedy akan di-binding di interface tunneling tun0 dan tun1
Disini saya tidak memasukkan hasil ifconfig saya, tapi ini cuma sebagai perbandingan aja. Sebagai catatan diperlukan waktu untuk dial ke speedy jadi ifconfig seperti ini tidak langsung keluar.
# ifconfig
tun0: flags=8051 mtu 1492
groups: tun egress
inet 125.xxx.xxx.113 –> 125.163.72.1 netmask 0xffffffff
tun1: flags=8051 mtu 1492
groups: tun
inet 125.xxx.xxx.114 –> 125.163.72.1 netmask 0xffffffff

f. Dan default gateway akan aktif

# netstat -nr |more
uttuk melihat list routing

g. Serta konfigurasi resolver DNS pun akan terisi secara otomatis

# cat /etc/resolv.conf
lookup file bind
nameserver 202.134.2.5
nameserver 203.130.196.5

h. Aktifkan Packet Firewall pf

# /etc/rc.conf
pf=”YES”

i. Script Packet Firewall NAT dan balancing dengan round-robin
#nano -w /etc/pf.conf
lan_net = “10.0.0.0/8? #IP client
int_if = “rl2? #interface LAN
ext_if1 = “tun0?
ext_if2 = “tun1?
ext_gw1 = “125.163.72.1?
ext_gw2 = “125.163.72.1?
# scrub all
scrub in all
# nat outgoing connections on each internet interface
nat on $ext_if1 from $lan_net to any -> ($ext_if1)
nat on $ext_if2 from $lan_net to any -> ($ext_if2)
# pass all outgoing packets on internal interface
pass out on $int_if from any to $lan_net
# pass in quick any packets destined for the gateway itself
pass in quick on $int_if from $lan_net to $int_if
# load balance outgoing tcp traffic from internal network.
pass in on $int_if route-to \
{ ($ext_if1 $ext_gw1), ($ext_if2 $ext_gw2) } round-robin \
proto tcp from $lan_net to any flags S/SA modulate state
# load balance outgoing udp and icmp traffic from internal network
pass in on $int_if route-to \
{ ($ext_if1 $ext_gw1), ($ext_if2 $ext_gw2) } round-robin \
proto { udp, icmp } from $lan_net to any keep state
# general “pass out” rules for external interfaces
pass out on $ext_if1 proto tcp from any to any flags S/SA modulate state
pass out on $ext_if1 proto { udp, icmp } from any to any keep state
pass out on $ext_if2 proto tcp from any to any flags S/SA modulate state
pass out on $ext_if2 proto { udp, icmp } from any to any keep state

j. Aktifkan script yang diperlukan di /etc/rc.local agar setiap reboot langsung bekerja.

ifconfig rl0 up
ifconfig rl1 up
# aktifkan speedy
ppp -ddial pppoe0
ppp -ddial pppoe1

PF akan langsung bekerja membaca /etc/pf.conf.
Jika harus me-restart koneksi DSL Speedy, pastikan pppoe dimatikan dulu

# pkill ppp

Jika tidak, maka ppp akan membuat tunneling baru menjadi tun2, tun3 dan seterusnya.

4. DHCP Server
Karena ga mau repot setting client aku juga disuruh pake DHCP untuk koneksi dari client.
Aktifkan service DHCP
#nano -w /etc/rc.local
ubah dhcpd_flags=NO menjadi dhcpd_flags=””

Menentukan interface yang akan digunakan
#nano -w /etc/dhcpd.interfaces
rl2 #interface LAN

Konfigurasi DHCP
rubah sesuai dengan keperluan
#nano -w /etc/dhcpd.conf
option domain-name “gw.sky.net”
option domain-name-servers 203.xxx.xxx.xxx, 203.xxx.xxx.xxx; #diisi dengan DNS
subnet 192.168.1.0 netmask 255.255.255.0
{
option routers 192.168.1.100; # gateway komputer client
range 192.168.1.1 192.168.1.64; #range ip yang digunakan client
}

keluar, save, reboot…………

Untuk setting load balance dan DHCP selesai. Untuk proxy sesuaikan dengan kebutuhan. Tinggal tambahkan redirector pada pf.conf ke port dan ip squid (tentunya jika kita menggunakan squid proxy, kalo tidak ga perlu).
Tambahkan rule berikut pada pf.conf , letakkan setelah rule nat.

rdr on $int_if proto tcp from any to any port 80 -> 192.168.1.100 port 3128

untuk mengecek pf gunakan command
pfctl -f /etc/pfctl #merestart
pfctl -sq #mengecek
pfctl -vvsq #monitoring
pfctl -sn #cek rule

PF:Getting Started
——————-
AKTIVASI
——————-

untuk aktifasi PF dan membaca konfigurasinya file tersebut saat booting, tambahkan :

pf=YES

di file /etc/rc.conf.local

reboot system anda untuk memperoleh hasil.

Anda dapat juga mengaktifkan dan deaktif PF menggunakan program pfctl:

#pfctl -e
#pfctl -d

Untuk mengenablekan dan disable, yang perlu di perhatikan bahwa ini hanya enable dan disable PF,

tidak secara benar meload ruleset. Ruleset harus di loaded sebelum atau setelah PF di enable.

KONFIGURASI
—————————

PF membaca konfigurasi rules dari /etc/pf.conf saat booting, seperti loading oleh script rc.

Perhatikan bahwa ketika /etc/pf.conf adalah default dan di loaded oleh sistem script rc, itu hanya

file teks yang diloaded dan di interpretasikan oleh pfctl dan di masukkan ke dalam pf. Untuk

beberapa aplikasi, rulesets yang lain mungkin di loaded dari file lain setelah booting. Sebagai

aplikasi di desain oleh oleh unix, PF menawarkan fleksibilitas yang baik.

pf.conf memliki tujuh bagian:
*Macros : variable user-defined yang dapat menahan IP address, nama interfaces, dll.
*Tables : sebuah struktur digunakan untuk menyatakan sekumpulan dari IP address
*Option :variasi pilihan untuk mengontrol bagaimana pf bekerja
*Scrub : Re-processing paket untuk menjadi normal dan mendefrag mereka.
*Queueing : Memberikan kontrol bandwidth dan proritas paket.
*Transalation : Kontrol Network Address Translation (NAT) dan paket redirection.
*Filter Rules : Memperbolehkan selektif terhadap filtering atau blocking terhadap paket ketika
mereka melalui interfaces.

Dengan pengecualian terhadap macros dan tables, setiap bagian seharusnya muncul dalam perintah ini

di dalam file konfigurasi, tidak semua bagian harus eksist dalam setiap aplikasi khusus.

KONTROL
———————–

Setelah booting, operasi PF dapat di manage menggunakan program pfctl. beberapa contoh program

adalah :

# pfctl -f /etc/pf.conf Load file pf.conf
# pfctl -nf /etc/pf.conf Parse file, tapi tidak load
# pfctl -Nf /etc/pf.conf Load hanya rule NAT dari file
# pfctl -Rf /etc/pf.conf Load hanya rule filter dari file

# pfctl -sn Tunjukkan rule NAT yang sedang berjalan
# pfctl -sr Tunjukkan rule filter yang sedang berjalan
# pfctl -ss Tunjukkan bentuk table yang sedang berjalan
# pfctl -si Tunjukkan bentuk filter dan counters
# pfctl -sa Tunjukkan SEMUANYA yang dapat di tunjukkan

Untuk lebih jelasnya baca manual mengenai pfctl
sumber:bimoseptyop.blogspot.com