Tproxy + bridge slackware 12.2

tutorial by mas anton genius ( thanx bwt semuanya, 5f tk copas dlu, catatanku blm seesai..hheuu) & other source from http://makassar-slackers.org/node/198

Ini adalah dokumentasi instalasi slackware 12.2 yang dikonfigurasi menjadi sebuah proxy server menggunakan squid dan tproxy, dengan tujuan IP yang keluar / terdeteksi di internet adalah IP client yang mengakses bukan IP milik router seperti yang digunakan dalam teknik nat

Perlengkapan :
:: Slackware 12.2 <instal yang perlu2 aja>
:: kernel linux v2.6.28.3 keatas
:: squid v3.1 keatas
:: iptables v1.4.3 keatas
:: ebtables v. terserah

Langkah :
1. Install Slackware-nya dulu
2. Upgrade kernel, caranya :
a. download dari kernel.org atau kambing.ui.edu
b. extract di /usr/src
me.# tar -xjvf $linux_source.tar.bz2
c. masuk kedirektori linux yang baru diextract ($linux_source)
me.# cd $linux_source
d. copy konfigurasi lama jadi .config di direktori $linux_source
me.# cp /boot/config /usr/src/.config
e. jalankan make menuconfig
me.# make menuconfig
pilih semua yang ada di

–>>Networking support
–>>Networking option
–>>Network packet filtering framework (NetFilter)
–>>IP: Netfilter Configuration
–>…

yang bisa built in <*> pilih built in, kalo ga bisa jadiin module [M]
keluar dari make menuconfig, save konfigurasi.
f. memastikan opsi berikut diload sebagai modul :
CONFIG_NETFILTER_TPROXY=m
CONFIG_NETFILTER_XT_TARGET_TPROXY=m
CONFIG_NETFILTER_XT_MATCH_SOCKET=m
pake nano gini:
me.# nano .config
cari opsi-opsi diatas dengan cara CTRL+W dan masukkan keyword
kalo masih kayak gini :
#CONFIG_NETFILTER_TPROXY is not set
rubah jadi
CONFIG_NETFILTER_TPROXY=m
lakuakn untuk ketiga opsi diatas…
g. mulai compile ini agak lama (1-2jam) tergantung kecepatan processor anda perintahnya :
me.# make all
h. install module
me.# make modules_install
i. copy/pindah file bzImage ke /boot
me.# cp /usr/src/$linux_source/arch/i386/bzImage /boot/bzImageBaru
j. edit lilo,
me.# nano /etc/lilo.conf
tambahkan baris berikut dibawah # Linux bootable partition config…
#————————-
image = /boot/bzImageBaru
root = /dev/sda1 # “/” ada dimana
label = Linux-Baru
read-only
#————————–
simpan…
k. jalankan lilo dengan konfigurasi yang telah dibuat tadi
me.# lilo -z
l. reboot, pilih label yang baru.

2. Load modul-modul yang diperlukan dengan modprobe :
#————————-
modprobe xt_TPROXY
modprobe xt_socket
modprobe nf_tproxy_core
modprobe xt_MARK
modprobe nf_nat
modprobe nf_conntrack_ipv4
modprobe nf_conntrack
modprobe nf_defrag_ipv4
modprobe ipt_REDIRECT
modprobe iptable_nat
#————————–
cek dengan lsmod, apakah modul-modul diatas sudah di load belum.

3. Install iptables.
a. download iptables-1.4.3 keatas
b. extract di /usr/src
me.# cd /usr/src
me.# tar -xjvf iptables-1.4.3.tar.bz2
c. kompile dan install
me.# cd iptables-1.4.3
me.# ./configure && make

4. Install squid
a. Download squid 3.1 keatas.
b. extract di /usr/src
me.# tar -xjvf squid-3.1.tar.bz2
me.# cd squid-3.1
c. configure, kompile, dan install
me.# ./configure  && \
–prefix=/usr \
–sysconfdir=/etc/squid \
–localstatedir=/var/log/squid \
–datadir=/usr/share/squid \
–mandir=/usr/man \
–enable-snmp \
–enable-linux-netfilter \
–enable-async-io
me.# make all && make install

5. Install ebtables

6. Buat bridge
#———————————————————————————
brctl addbr bridge-baru
ifconfig eth0 0.0.0.0 promisc up
ifconfig eth1 0.0.0.0 promisc up
brctl addif bridge-baru eth0
brctl addif bridge-baru eth1
ifconfig bridge-baru 192.168.12.30 netmask 255.255.255.240 dstaddr 192.168.12.17
route add default gw 192.168.12.17 dev bridge-baru
#———————————————————————————-

7. Atur rule ebtables dan iptables
#————————————————————————————————————-
# note eth0=public, eth1=local, bridge-baru bridging eth0 & eth1
#————————————————————————————————————-
ebtables -t broute -I BROUTING -i eth1 -p ipv4 –ip-proto tcp –ip-dport 80 -j redirect –redirect-target DROP
ebtables -t broute -I BROUTING -i eth0 -p ipv4 –ip-proto tcp –ip-sport 80 -j redirect –redirect-target DROP
iptables -t mangle -N DIVERT
iptables -t mangle -A DIVERT -j MARK –set-mark 1
iptables -t mangle -A DIVERT -j ACCEPT
iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT
iptables -t mangle -A PREROUTING -i eth1 -p tcp –dport 80 -j TPROXY –tproxy-mark 0x1/0x1 –on-port 3128
echo 1 > /proc/sys/net/ipv4/ip_forward
ip rule add fwmark 1 lookup 100
ip route add local 0.0.0.0/0 dev lo table 100

cd /proc/sys/net/bridge/
for i in *
do
echo 0 > $i
done
unset i

ip ro flu ca
#————————————————————————————————————-

8. Atur squid.conf
me.# nano /etc/squid/squid.conf
9. Membuat service/startup biar langsung jalan kalo kompie reboot
A. untuk squid :
a. buat script bash seperti ini
me.# nano /etc/rc.d/rc.squid

isi dari rc.squid:
# —————————————————-
# ini file /etc/rc.d/rc.squid
#!/bin/sh
echo -n ‘squid’
echo “$1” in
start)
/usr/sbin/squid -D
;;
stop)
/usr/sbin/squid -k shutdown
;;
restart)
/usr/sbin/squid -k reconfigure
;;
*)
echo “Usage : ‘basename $0’ {start|stop|restart}”
;;
esac
#——————————————————
b. buat agar rc.squid supaya bisa di eksekusi
me.# chmod 755 /etc/rc.d/tc.squid
c. buat agar di load otomatis saat booting
me.# nano /etc/rc.d/rc.inet2
d. tambahkan baris berikut pada rc.inet2
#———————————–
#start SQUID (Squid proxy server)
if [-x /etc/rc.d/rc.squid]; then
./etc/rc.d/rc.squid start
fi
#———————————–

B. Untuk bridge dan rule ebtables dan iptables….
a. untuk load modul :

b. untuk bridge :

c. untuk ebtables dan iptables cukup dengan perintah save :
me.# iptables-save
me.# ebtables-save

12 thoughts on “Tproxy + bridge slackware 12.2

  1. configurasi squidnya agak aneh soale nda ada enable-tproxynya 😛 ini agak aneh paling jalan kerna = squid biasa atau memang ada keterangan yg menyatakan tdk pake enable tproxynya jalan di squid
    mohon pencerahan

  2. Hey are using WordPress for your site platform?
    I’m new to the blog world but I’m trying to get started and create
    my own. Do you require any html coding expertise to make your own blog?

    Any help would be really appreciated!

Leave a comment