Alahmldh walaupun terpatah patah akhirnya bisa jadi jg proxy server freebsd ku.Konfigurasi dari selesai install os, compile kernel, install squid, configurasi squid, Nat dengan pf selesai jg dan bisa running.Tidak lain jg hasil tanya sana sini thx buat mas Danangyanto, mas Bani, Mas Afif.
untuk memulai konfigurasi proxy server dengan freebsd ada beberapa hal yg harus di lewati :D .saya menggunakan 3 buah interface yaitu "rl2" #Interface untuk IP Public ISP, "rl0" #Interface untuk IP Public Speedy, "rl1" #Interface untuk IP LAN.
Untuk konfigurasi ip di setiap interface lakukan edit di file /etc/rc.conf
ifconfig_rl2="inet 114.xxx.xx.xx netmask 255.255.255.0"
ifconfig_rl1="inet 192.168.0.111 netmask 255.255.255.0"
ifconfig_rl0="inet 192.168.111.3 netmask 255.255.255.0"
defaultrouter="114.xxx.xx.xx"
hostname="nasrulkurniawan.net"
kemudian setelah memastikan koneksi kemasing masing dari setiap interface baik, setting file /etc/resolv.conf dan masukkan dns dari isp dan speedy
domain net
nameserver 114.xxx.xx.x
nameserver 192.168.111.2
sampai di sini seharusnya anda sudah bisa ping ke google.com.Selanjutnya compile kernel dan masing masing options di bawah ini punya maksud dan tujuan knp harus di include kan di kernel.
---------- copy here to kernel --------------------------------------
#untuk dukungan squid
options MSGMNB=32768 # jumlah maksimal byte yang disimpan di
options MSGMNI=164 # jumlah message queue identifiers
options MSGSEG=8196 # jumlah message segments per queue
options MSGSSZ=512 # besarnya sebuah message segment
options MSGTQL=2048 # jumlah maksimal messages pada syste
#Untuk NAT################################
options IPFIREWALL
options IPDIVERT
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPFIREWALL_VERBOSE
#Untuk PF#################################
device pf
device pflog
device pfsync
options ALTQ
options ALTQ_CBQ # Class Bases Queuing (CBQ)
options ALTQ_RED # Random Early Detection (RED)
options ALTQ_RIO # RED In/Out
options ALTQ_HFSC # Hierarchical Packet Scheduler (HFSC)
options ALTQ_PRIQ # Priority Queuing (PRIQ)
options ALTQ_NOPCC # Required for SMP build
#Untuk PF#################################
------------------------- akhir -----------------------------------
Squid berfungsi untuk cache server dan pf untuk nat dan loadbalancing.copy kode di atas kemudian lakukan perintah sebagai berikut untuk memulai konfigurasi dan compile kernel.
nasrulkurniawan# cd /usr/src/sys/i386/conf
nasrulkurniawan# cp GENERIC PF
nasrulkurniawan# ee PF
tambahkan script yg ada di atas kemudian simpan file PF.lanjutkan lagi ke syntax di bawah ini:
nasrulkurniawan# config PF
nasrulkurniawan# cd ../compile/PF
nasrulkurniawan# make cleandepend
nasrulkurniawan# make depend
nasrulkurniawan# make && make install
jgn panik dr langkah - langkah di atas klu terjadi error biasanya di langkah - langkah ini sering terjadi error teliti dengan seksama errornya apa, kemudian copy paste error tersebut ke google dari situ insyallah pasti ada solusi setiap masalah error.Reboot & Ok Next >>
selanjutnya setting squid.untuk setting squid download squid terbaru dri site squid.copy di /usr/local/
nasrulkurniawan# wget http://www.squid-cache.org/Versions/v2/2.7/squid-2.7.STABLE6.tar.gz
nasrulkurniawan# cp squid-2.7.STABLE6.tar.gz /usr/local
nasrulkurniawan# tar zxvf squid-2.7.STABLE6.tar.gz
nasrulkurniawan# cd squid-2.7.STABLE6
nasrulkurniawan# ./configure -prefix=/usr/local/etc/squid -enable-gnuregex -enable-async-io=24 -with-aufs-threads=24 -with-pthreads -with-aio -with-dl -enable-storeio=ufs,diskd -enable-storeio=diskd,ufs -enable-removal-policies=heap -enable-removal-policies=lru
nasrulkurniawan# make && make install
selesai baru kemudian edit file squid.conf di /usr/local/etc/squid/etc/squid.conf
bisa di ambil contohnya di http://geocities.com/nasrulkurniawan/squid.txt
simpan file tersebut kemudian membuat user untuk squid & group squid
nasrulkurniawan# pw groupadd squid
nasrulkurniawan# pw adduser squid -g squid -s /nonexistent
nasrulkurniawan# mkdir /cache1;chmod 777 /cache1 (membuat direktory untuk cache)
nasrulkurniawan# chown -R squid:squid /cache1
nasrulkurniawan# touch /usr/local/etc/squid/var/logs/access.log
nasrulkurniawan# touch /usr/local/etc/squid/var/logs/cache.log
nasrulkurniawan# chmod 777 /usr/local/etc/squid/var/logs/access.log
nasrulkurniawan# chmod 777 /usr/local/etc/squid/var/logs/cache.log
nasrulkurniawan# chown -R /usr/local/etc/squid/
nasrulkurniawan# /usr/local/etc/squid/sbin/squid -z
nasrulkurniawan# /usr/local/etc/squid/sbin/squid -D (menjalankan squid)
test squid client
nasrulkurniawan# squidclient -h 192.168.0.1 -p 3128 http://www.google.com
nasrulkurniawan# tail -f /usr/local/etc/squid/var/logs/access.log
jgn lupa membuat script sederhana untuk menjalankan squid saat komputer restart
nasrulkurniawan# touch /usr/local/etc/rc.d/script.sh
---------------------- copy kode -----------------------
#!/bin/sh
/usr/local/etc/squid/sbin/squid -D
/usr/local/etc/squid/sbin/squid -DNY &
/sbin/ipfw add 30000 allow tcp from 192.168.0.111 to any 80
/sbin/ipfw add 30010 fwd 192.168.0.111,3128 tcp from any to any 80
---------------------- akhir kode ------------------------------
------------catatan penting saya ----------------------------------------------
test -z "/usr/local/etc/squid/bin" || /usr/local/squid-2.7.STABLE6/cfgaux/install-sh -d "/usr/local/etc/squid/bin"
/usr/bin/install -c 'squidclient' '/usr/local/etc/squid/bin/squidclient'
test -z "/usr/local/etc/squid/libexec" || /usr/local/squid-2.7.STABLE6/cfgaux/install-sh -d "/usr/local/etc/squid/libexec"
/usr/bin/install -c 'cachemgr.cgi' '/usr/local/etc/squid/libexec/cachemgr.cgi'
/usr/bin/install -c -m 644 ./cachemgr.conf /usr/local/etc/squid/etc/cachemgr.conf
-------------------------------------------------------------------------------
restart komputer dan squid sudah siap di pakai, selanjutnya membuat nat dan loadbalancing dengan pf
nasrulkurniawan# ee /etc/pf.conf
copy paste script di bawah ini
----------- mulai copy ----------------------------
lan_net = "192.168.0.0/24"
int_if = "rl1"
ext_if1 = "rl2"
ext_if2 = "rl0"
ext_gw1 = "114.141.57.49"
ext_gw2 = "192.168.111.2"
# 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)
#transparan proxy
rdr on $int_if proto tcp from any to any port www -> 192.168.0.1 port 3128
# 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
-------------- batas copy---------------------------------------
simpan file pf.conf
nasrulkurniawan# pfctl -F all (untuk nge flush firewall)
nasrulkurniawan# pfctl -f /etc/pf.conf
setelah firewall nya jalan, anda dapat melihat settingan yang sedang berjalan, caranya adalah :
nasrulkurniawan# pfctl -s all |more
reeboot lagi komputer server anda untuk lanjutkan ke langkah berikutnya yaitu membuat list untuk routing
nasrulkurniawan# cd /usr/local/etc/rc.d/
nasrulkurniawan# touch route_speedy.sh (menjalankan routing saat komputer booting)
--------------- copy kode ini --------------------------------------
#!/bin/sh
route add 202.65.113.16 192.168.111.2
-------------- akhir kode -----------------------------------------
nasrulkurniawan# chmod 777 route_speedy.sh (agar bisa di eksekusi saat awal booting)
nasrulkurniawan# touch /usr/local/etc/rc.d/del_route_speedy.sh
konfigurasi untuk memfungsikan proxy sbg dns
nasrulkurniawan# ee /etc/namedb/named.conf
edit line yang ada tulisan :
listen-on { 127.0.0.1; 192.168.0.111;}; //192.168.0.111 ip yg terhubung ke LAN
buka options :
forward only;
jg line ini :
forwarders {
114.xx.xx.x; //ip dns kamu
};
nasrulkurniawan# /etc/rc.d/named restart
nasrulkurniawan# nslookup - 192.168.0.111
> yahoo.com
ok sampai disini semua udah kelar dan proxy siap di gunakan ^^