SQUID with tproxy

Proxy Squid dengan tproxy

Acuan dari

  • http://wiki.squid-cache.org/Features/Tproxy4
  • http://www.visolve.com/squid/squid-tproxy.php
  • http://www.visolve.com/squid/tproxy4/
  • http://wiki.squid-cache.org/SquidFaq/InterceptionProxy#head-5887c3744368f290e63fda47fd1e4715c9bdbc9b
  • Software yang Dibutuhkan

    Linux Kernel 2.6.39.3
    iptables 1.4.10
    Squid 3.1
    libcap-dev or libcap2-dev
    libcap 2.09 or later

    Pekerjaan di Mesin Squid

    Compile Kernel :
    Tambahan yang harus di lakukan
    NF_CONNTRACK=m
    NETFILTER_TPROXY=m
    NETFILTER_XT_MATCH_SOCKET=m
    NETFILTER_XT_TARGET_TPROXY=m

    Boot Script

    Masukkan ke salah satu boot script misal rc.local
    echo 0 > /proc/sys/net/ipv4/conf/eth0/rp_filter
    echo 1 > /proc/sys/net/ipv4/ip_forward

    Bila memakai SELINUX

    setsebool squid_connect_any=yes
    setsebool squid_use_tproxy=yes

    Script iptables untuk membuat transparent proxy

    buat file di /usr/local/sbin/tproxy

    #!/bin/sh

    case “$1” in
    ‘start’)
    iptables -t mangle -N DIVERT
    iptables -t mangle -A DIVERT -j MARK –set-mark 0x1/0x1
    iptables -t mangle -A DIVERT -j ACCEPT
    iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT
    iptables -t mangle -A PREROUTING -p tcp –dport 80 -j TPROXY –tproxy-mark 0x1/0x1 –on-port 3129
    ip rule add fwmark 1 lookup 100
    ip route add local 0.0.0.0/0 dev lo table 100
    ;;
    ‘stop’)
    ip route del local 0.0.0.0/0 dev lo table 100
    ip rule del fwmark 1 lookup 100
    iptables -t mangle -D PREROUTING -p tcp –dport 80 -j TPROXY –tproxy-mark 0x1/0x1 –on-port 3129
    iptables -t mangle -D PREROUTING -p tcp -m socket -j DIVERT
    iptables -t mangle -D DIVERT -j ACCEPT
    iptables -t mangle -D DIVERT -j MARK –set-mark 0x1/0x1
    iptables -t mangle -X DIVERT
    ;;
    ‘restart’)
    /usr/local/sbin/tproxy stop
    /usr/local/sbin/tproxy start
    ;;
    ‘edit’)
    pico /usr/local/sbin/tproxy
    ;;
    *)
    echo “Usage: $0 {start|stop|restart}”
    ;;
    esac

    Pekerjaan di Gateway

    to be continue

    This entry was posted by Wiendy on Friday, July 22nd, 2011 at 2:32 AM and is filed under Linux . You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

    Leave a Reply

    Categories