[Manual] Creating Transparent Proxy With squid and IPTables



For creating transparent proxy we need edit squid.conf and add iptables rules.

  1. Edit /etc/squid.conf file with your favorite editor, example vi
    vi /etc/squid.conf

    Add or change this lines.

    http_port 192.168.5.1:8888
    cache_peer [your_proxy] parent 8080 0 no-query
    cache_dir ufs /var/spool/squid 5000 16 256
    acl clients src [your clients' network, ex. 192.168.5.0/255.255.255.0]
    acl all src 0.0.0.0/0.0.0.0
    http_access allow clients
    http_access deny all
  2. Add iptables rules
    iptables -t nat -A PREROUTING -s 192.168.5.0/24 -d ! 192.168.5.1 -p tcp -m multiport --dport 80,81,82,83,88,8000,8001,8002,8080,8081 -j REDIRECT --to-port 8888
    iptables -t nat -A PREROUTING -s 192.168.5.0/24 -d ! 192.168.5.1 -p udp -m multiport --dport 80,81,82,83,88,8000,8001,8002,8080,8081 -j REDIRECT --to-port 8888
    iptables -t nat -A PREROUTING -s 192.168.5.0/24 -d ! 192.168.5.1 -p tcp -m multiport --dport 8082,8083,8091,8100,8101,8102,8103,8080,777 -j REDIRECT --to-port 8888
    iptables -t nat -A PREROUTING -s 192.168.5.0/24 -d ! 192.168.5.1 -p udp -m multiport --dport 8082,8083,8091,8100,8101,8102,8103,8080,777 -j REDIRECT --to-port 8888

[green]In this example we set up transparent proxy server with ip 192.168.5.1 listens port 8888[/green]

No Responsesto “[Manual] Creating Transparent Proxy With squid and IPTables”

Trackbacks/Pingbacks

  1. Transparent Proxy with Squid / iptables - Just just easy answers - [...] here you can see a brief article about transparent proxy with squid and iptables http://www.linuxconfig.net/2009/11/14/creating-transparent-proxy-with-squid-and-iptables.html [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>