Feed on Posts or Comments 09 July 2008

Category ArchiveLinux Server



Proxy (Squid) IWaN RySTiONo on 10 Apr 2008

Pemecahan kasus squid yang refusing

Sodara M. Gunawan memberikan listing configurasi squid kepada kami. Masalahnya adalah proxy sering refusing. Ini adalah aslinya:

# WELCOME TO SQUID 2# ——————
http_port 192.168.0.1:3128 transparent

###no cache at cgi………………………..
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
###caching set……………………………
cache_mem 32 MB
maximum_object_size 4096 KB
maximum_object_size_in_memory 16 KB
# log_mime_hdrs on
# ftp_passive on
###timing access…………………………
forward_timeout 3 minutes
connect_timeout 2 minutes
read_timeout 4 minutes
request_timeout 1 minutes
###access_list…………………………..
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 SSL_ports port 443 563
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 # gopheracl 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
###access_control………………………..
acl porn url_regex “/etc/squid/porn”
acl noporn url_regex “/etc/squid/noporn”
http_access deny porn !noporn
acl our_MASTER src 192.168.0.1
http_access allow our_MASTER
http_access allow our_MASTER localhost
######################all_client…………..
acl user1 src 192.168.0.2
acl user2 src 192.168.0.3
acl user3 src 192.168.0.4
acl user4 src 192.168.0.5
acl user5 src 192.168.0.6
acl user6 src 192.168.0.7
acl user7 src 192.168.0.8
acl user8 src 192.168.0.9
acl user9 src 192.168.0.10
acl user10 src 192.168.0.11
acl user11 src 192.168.0.12
acl user12 src 192.168.0.13
acl user13 src 192.168.0.14
acl user14 src 192.168.0.15
acl user15 src 192.168.0.16
acl ubuntu src 192.168.0.18
######################allow user
http_access allow user1
http_access allow user2
http_access allow user3
http_access allow user4
http_access allow user5
http_access allow user6
http_access allow user7
http_access allow user8
http_access allow user9
http_access allow user10
http_access allow user11
http_access allow user12
http_access allow user13
http_access allow user14
http_access allow user15
http_access allow ubuntu
#######################
http_access deny all
logfile_rotate 5

visible_hostname WAWAN_KWOK@ndeso

Nah, ternyata masalahnya adalah pada masalah peletakan acl yang tidak beraturan.

Mungkin bisa disederhanakan menjadi begini:

# WELCOME TO SQUID 2 #
http_port 192.168.0.1:3128 transparent

###no cache at cgi………………………..
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY

###caching set #######
cache_mem 32 MB
maximum_object_size 4096 KB
maximum_object_size_in_memory 16 KB
# log_mime_hdrs on
# ftp_passive on

###timing access #####
forward_timeout 3 minutes
connect_timeout 2 minutes
read_timeout 4 minutes
request_timeout 1 minutes

### access_list ########
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 SSL_ports port 443 563
acl Safe_ports port 80 21 443 563 70 280
acl Safe_ports port 488 591 777 1025-65535
acl CONNECT method CONNECT
acl POST method POST
acl porn url_regex “/etc/squid/porn”
acl noporn url_regex “/etc/squid/noporn”
acl our_MASTER src 192.168.0.1
acl user src 192.168.0.2-192.168.0.15/255.255.255.0
acl ubuntu src 192.168.0.18/32

#### policy ####
http_access deny !noporn porn
http_access allow our_MASTER localhost user ubuntu
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny all

always_direct allow POST
always_direct deny all

logfile_rotate 5
visible_hostname WAWAN_KWOK@ndeso

Jika hasilnya masih tetep sama, maka bergantung pada file porn dan noporn. Silahkan di tweak disitu. Terutama bagian penulisan keyword yang di restrict.

Proxy (Squid) IWaN RySTiONo on 25 Sep 2007

Mudahnya transparent proxy dengan squid 2.6

Sebenarnya agak telat nulis ini. Squid 2.6 udah lama release, tapi aku masih pake yang 2.5. Dasar emang admin pemalas. Update aja males. :D

Aku baru terasa bingung waktu setting di kediri. Kok konfigurasi squid ku nggak bekerja? sampai pusing ni kepala. Akhirnya, dengan tekad yang bulat bertanya kepada mbah Google. Kemudian mbah google menganjurkan aku untuk mengunjungi Mbah Wiki Deckle. Disitu baru tau, ternyata bedanya agak jauh.

httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on

Bagian yang ini. Dihapus secara keseluruhan, gantinya di http_port dikasi option transparent.

http_port 3128 transparent

Ternyata gini doank. :D

Gitu aja sampe pusing tujuh keliling. Coba kalo dari awal tanya mbah Google, pasti nggak akan pusing kan?

Distro & Firewall IWaN RySTiONo on 06 Sep 2007

pfSense Firewall

About
pfSense is a open source firewall derived from the m0n0wall operating system platform with radically different goals such as using OpenBSD’s ported Packet Filter, FreeBSD 6.1 ALTQ (HFSC) for excellent packet queueing and finally an integrated package management system for extending the environment with new features.

As with the software itself, this website is still a work in progress, but we’re actively working on improving and completing it.

Minimum hardware requirements

  1. All platforms: 128 megabytes of RAM.
  2. Embedded: 128 megabyte compact flash card.
  3. Full installation: 2Gb hard drive or larger.
  4. LiveCD: USB Keychain for configuration storage.

Download
You can get pfSense for free at here.

Tutorial?
There are many tutorial for this stuff at oficial website. Or you can find a few at my blog. This is the tutorial that can i give for this moment. All in Indonesian language.

  1. Instalasi pfSense
  2. pfSense Traffic Shapper
  3. pfSense PPPoE server & client (coming soon…)

Linux Server IWaN RySTiONo on 29 Aug 2007

Policy Routing

Taken from forum.rtrw.net.

Gw bingung mo kasih judul apa Thread ini, gambarannya gini, misal gw punya koneksi internet dari 2 ISP terus traffic Client VIP mau gw lewatin ISP 2 dan traffic Client Normal mau gw lewatin di ISP 1 (default).

Diketahui :

eth0 = 192.168.1.1 = LAN
eth1 = 1.1.1.2 = ISP1
eth2 = 2.2.2.2 = ISP2
Gateway ISP 1 = 1.1.1.1
Gateway ISP 2 = 2.2.2.1
Client VIP = 192.168.1.100 - 192.168.1.150
Netmask : /24 (255.255.255.0)

Ditanyakan:

Bagaimana agar semua traffic Client Normal bisa lewat ISP 1 dan Client VIP lewat ISP 2 ?

Penyelesaian :

  1. Buka Console Linux sebagai user dengan hak administrator
  2. Tambahkan Routing Table untuk ISP2
    # echo 1 ISP2 >> /etc/iproute2/rt_tables
  3. Bikin file baru dengan nama multiclient
    # vi /etc/multiclient
  4. Tekan tombol Insert untuk mulai mengedit file tsb
  5. Isi file tersebut seperti dibawah ini :

    # Tambahkan default route
    route add -net 0.0.0.0/0 gw 1.1.1.1
    route add -net 0.0.0.0/0 gw 2.2.2.1 metric 2 dev eth2

    # Disini, Paket dari Client VIP akan di tandai dengan tanda “1″
    /sbin/iptables -A PREROUTING -t mangles -i eth0 -p ALL -m iprange –src-range 192.168.1.100-192.168.1.150 -j MARK –set-mark 1

    # Tambahkan rule di routing table ISP2
    ip route add default via 2.2.2.1 dev eth2 table ISP2

    # Disini rule akan membaca dari table mangle, paket mana yang ditandai “1″
    # dan apabila benar (paket ditandai) maka akan dilewatkan di routing
    # table ISP2 bukan di default (ISP1)
    ip rule add from all fwmark 1 table ISP2

    Tekan tombol escape (esc)
    Ketik “:wq” (tanpa tanda kutip) kemudian enter

  6. Buat file multiclient dapat dieksekusi
    # chmod 775 /etc/multiclient
  7. Masukkan ke rc.local supaya setiap reboot file multiclient dijalankan.

Untuk mengecek apakah sudah berhasil, trace route dari Client VIP dan lihat apakah route lewat ISP2 …

Semoga berhasil, mohon dibetulkan kalo ada yang salah …

Terima kasih,

Linux Server IWaN RySTiONo on 19 Jul 2007

Kernel is too old…apa maksudnya?

Iseng-iseng kemaren coba install Zenserver. Aku coba install di komputer gateway warnet sparkle yang rusak. Speknya Pentium III 450Mhz, Ram 128Mb SDR, HDD 4Gb+20Gb. Prosesi install seperti tradisi Slackware, text mode gitu deh….

Setelah install harus restar untuk booting dari HDD. Waktu booting pertama, kok keluar message “kernel is too old“. Habis tuh ga lanjut, diem mulu and berkali-kali keluar message itu. Akhirnya aku install Slackware 10.1 seperti biasa, karena yang punya udah nungguin.

Mungkin ada yang tau kenapa ya dengan Zenserver? Padahal kan hardwarenya yang lama. Salah message kali ya? Harusnya “Hardware is too old“, itu baru benar. =))

But, i’ll try again later deh…. :)

Linux Server IWaN RySTiONo on 11 Jul 2007

Konfigurasi Squid sebagai Transparant Proxy

Hari gini masih pake Windows buat server? Wah…ketinggalan jaman lu coy!

Beberapa saat yang lalu aku mendapat panggilan dari 3 warnet untuk membuat proxy server dengan Linux. Bukan berarti aku dapet banyak duit nih, sekali lagi bukan coz warnet-warnet ini milik teman sendiri. =))

Kebetulan, temen-temen di warnet ini pada kreatif semua. Mereka nggak nunggu aku, coz mereka maklum kalo selalu sibuk. Jadi mereka menginstall dahulu linux tersebut walau harus berkali-kali install karena dianggap gagal. Mereka dapet referensi dari Mbah Google, emang Google is the best deh. Jadi aku semakin ringan deh kerjanya.

Instalasi yang dilakukan temen-temen ternyata mereka sudah memasukkan squid dan iptables di dalamnya. Untung 2x nih…

Continue Reading »

Firewall IWaN RySTiONo on 29 Jun 2007

[Iptables] Blocking Port untuk Worm-worm

Temen-temen yang sebel kenapa internetnya lambat dan selalu ada traffic padahal komputer gak ada yang make, bisa coba deh block beberapa port yang dipake oleh Worm ini.

#!/bin/bash
IPT=`which iptables`
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 1 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 1 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 5 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 5 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 11 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 11 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 13 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 13 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 17 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 17 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 18 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 18 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 19 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 19 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 69 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 69 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 135 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 135 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 445 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 445 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 12345 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 12345 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 27374 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 27374 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 31337:31338 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 31337:31338 -j DROP
$IPT -I INPUT -p tcp -s 0/0 -d 0/0 –dport 65000 -j DROP
$IPT -I INPUT -p udp -s 0/0 -d 0/0 –dport 65000 -j DROP

Ini adalah skrip sederhana, sudah jadi dan dapat langsung dieksekusi.

Ok, selamat mencoba…. :-)

DNS IWaN RySTiONo on 29 Jun 2007

Membuat Server DNS Sendiri

Pada Distro Slackware, sudah ada paket Bind, yaitu DNS server. Secara default, Bind akan bekerja, namun perlu dilakukan setting agar dapat bekerja dengan optimal. Berikut langkah-langkahnya.

Download file named.cache

wget http://www.internic.net/zones/named.cache

 

Kemudian masuk /var/named/caching-example

cd /var/named/caching-example

 

Buang file named.ca dari direktori tersebut.

rm -rf named.ca

 

Dengan asumsi kita download named.cache di /root, maka kita salin file tersebut di direktori /var/named

cp /root/named.cache /var/named/named.ca

 

Pindahkan semua isi direktori caching-example ke parent direktorinya (/var/named) dan hapus direktori caching-example.

mv ./* ../ && cd ../ && rm -rf caching-example

 

Lalu rubah file /etc/named.conf menjadi seperti di bawah ini:

options {
directory “/var/named”;
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
query-source address * port 53;
};

 

//
// a caching only nameserver config
//
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone “.” IN {
type hint;
file “named.ca”;
};

zone “localhost” IN {
type master;
file “localhost.zone”;
allow-update { none; };
};

zone “0.0.127.in-addr.arpa” IN {
type master;
file “named.local”;
allow-update { none; };
};

include “/etc/rndc.key”;

 

Lalu, rubah file /etc/resolv.conf menjadi seperti di bawah ini:

nameserver 127.0.0.1
nameserver 202.152.0.2
nameserver 202.134.1.10

Baris kedua dan ketiga adalah opsional, untuk jaga-jaga kalo server DNS kita tiba-tiba mati.

 

Lakukan test query :

root@cache-bone01:~# host yahoo.com
yahoo.com has address 66.94.234.13
yahoo.com has address 216.109.112.135
yahoo.com mail is handled by 1 a.mx.mail.yahoo.com.
yahoo.com mail is handled by 1 b.mx.mail.yahoo.com.
yahoo.com mail is handled by 1 c.mx.mail.yahoo.com.
yahoo.com mail is handled by 1 d.mx.mail.yahoo.com.
yahoo.com mail is handled by 1 e.mx.mail.yahoo.com.
yahoo.com mail is handled by 1 f.mx.mail.yahoo.com.
yahoo.com mail is handled by 1 g.mx.mail.yahoo.com.
root@cache-bone01:~#

Jika hasilnya seperti diatas, maka DNS server siap dipakai.

 

Sekarang set Primary DNS komputer client dengan IP dari DNS server ini. Sedangkan, secondary DNS adalah DNS dari ISP anda. Buat abang-abang yang di Lintasarta dan Telkom, sorry ye….DNS nye ane pake buat contoh. ^_^

Selamat mencoba… :-)