IGOS Nusantara Dan Proxy Server Squid Trik: Konfigurasi Lain

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

IGOS Nusantara dan proxy server squid trik

Dari IGNwiki
Langsung ke: navigasi, cari Bagian ini membahas beragam trik terkait squid dan iptables, anatar lain: 1. 2. 3. 4. 5. Membuat skrip iptables untuk redirect Perintah iptables jika pakai ppp0 Blok satu IP ... lain-lain

Konfigurasi Lain

Koneksi langsung ke server lokal


Misal ada dua server lokal: 1. Server Web ada di 192.168.0.10 2. Server Billing ada di 192.168.0.20 Tambahkan rule
acl server dst 192.168.0.10/255.255.255.255 acl billing dst 192.168.0.20/255.255.255.255 always_direct allow server no_cache deny server always_direct allow billing no_cache deny billing

Koneksi langsung ke domain tertentu


Beberapa situs tidak tampil jika melalui proxy, sehingga perlu memakai koneksi langsung (tanpa proxy). Misal situs yang perlu akses langsung adalah "bank.co.id"
## ACL dipasang di awal ## ACL agar direct ke bank.co.id acl direct_domain url_regex bank.co.id always_direct allow direct_domain always_direct deny all ## ACL (Contoh lain) di bawahnya acl windowsupdate dstdomain wustat.windows.com

acl windowsupdate2 url_regex -i windowsupdate ## ACL Akses acl jaringanku src 192.168.0.0/24 acl hotspot src 10.1.0.0/24 http_access allow !windowsupdate !windowsupdate2 jaringanku http_access allow !windowsupdate !windowsupdate2 hotspot http_access deny all # ...

Skrip iptables
skrip iptables untuk mengatur redirect ke proxy server squid port 3128 Skema Jaringan http://igos-nusantara.or.id/wiki/Skema_Jaringan
#!/bin/sh # IP proxy server squid SQUID_SERVER="192.168.0.1" # Interface terkoneksi ke Internet INTERNET="eth0" # Interface terkoneksi ke LAN LAN_IN="eth1" # Squid port SQUID_PORT="3128" # Bersihkan iptables -F iptables -X iptables -t iptables -t iptables -t iptables -t firewall lama nat -F nat -X mangle -F mangle -X

# Muat modul IPTABLES untuk NAT dan sukungan IP conntrack modprobe ip_conntrack modprobe ip_conntrack_ftp # Untuk klien ftp win xp #modprobe ip_nat_ftp echo 1 > /proc/sys/net/ipv4/ip_forward # Seting filter default iptables -P INPUT DROP iptables -P OUTPUT ACCEPT # Unlimited access to loop back iptables -A INPUT -i lo -j ACCEPT iptables -A OUTPUT -o lo -j ACCEPT # Allow UDP, DNS and Passive FTP iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT # set this system as a router for Rest of LAN

iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT # unlimited access to LAN iptables -A INPUT -i $LAN_IN -j ACCEPT iptables -A OUTPUT -o $LAN_IN -j ACCEPT # DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$SQUID_PORT # if it is same system iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT -to-port $SQUID_PORT # DROP everything and Log it iptables -A INPUT -j LOG iptables -A INPUT -j DROP

Interface ke internet pakai ppp0


Atur agar NAT memakai ppp0
# iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

Pengalihan ke IP dan Port


Protokol jenis TCP yg masuk melalui interfaces eth1 dan port 80 akan dialihkan ke IP 192.168.0.1 dan port 3128/PROXY
# iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --todestination 192.168.0.1:3128

Blok satu IP
Cara blok salah satu IP untuk tidak diperbolehkan mengakses situs facebook.com Contoh: IP 192.168.0.3 ---> blok koneksi ke facebook.com IP all ---> bolek koneksi ke facebook.com Pakai squid:
acl bad_ip src 192.168.1.3/32 acl good_ip src 192.168.1.0/24 acl facebook_deny url_regex -i "facebook.com" http_access deny bad_ip facebook_deny http_access allow good_ip

Pakai iptables:
-A PREROUTING -i local_eth -d facebook.com -s 192.168.0.3 -j DROP

Redirect ke SSH Server


Akses ke port 22/TCP yg masuk dari interfcaes ppp0 akan diarahkan ke ip 192.168.0.2 (SSH Server)
# iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 22 -j DNAT --todestination 192.168.0.2

Blok dan Buka beberapa situs


Buat dan jalankan skrip
cat > /tmp/situs_daftar << EOF.jr facebook.com detik.com yahoo.com EOF.jr cat > /tmp/situs_blok << EOF.ns #!/bin/sh while read situs do iptables -A PREROUTING -i local_net -s ip_target -d $situs -j DROP done < /tmp/situs_daftar EOF.ns cat > /tmp/situs_buka << EOF.jr #!/bin/sh while read situs do iptables -D PREROUTING -i local_net -s ip_target -d $situs -j DROP done < /tmp/situs_daftar EOF.jr

1. Spesifikasi Server
Sistem Operasi memakai IGOS Nusantara 2010 (Instal minimal) Posesor Intel(R) Xeon(TM) CPU 3.00GHz RAM 1 GB (yup memori masih kecil, harusnya update ke 4 GB) Harddisk 2 x 80 GB SCSI o Harddisk1: /dev/sda (untuk menyimpan sistem operasi) o Harddisk2: /dev/sdb (untuk menyimpan cache squid)

Berikut ini kompilasi squid untuk spesifikasi: 1. 2. 3. 4.

5. 5. Buat swap
6. Setelah konfigurasi squid.conf dilakukan, kini saatnya menjalankan squid. Ketikkan perintah agar squid membuat swap
7. # /usr/sbin/squid -z

You might also like