Tuesday, August 24, 2010

~ Squid Transparent Proxy in Ubuntu~

Squid: Optimising Web Delivery
Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It reduces bandwidth and improves response times by caching and reusing frequently-requested web pages. Squid has extensive access controls and m
akes a great server accelerator. It runs on most available operating systems, including Windows and is licensed under the GNU GPL.

What we need before install Squid?

1. 1 PC
2. ubuntu 10.04 installer
3. NIC (2 ports)
How to configure squid?

Ok 1st we should install ubuntu 10.04 desktop on pc.... Then after installation finish, we need to update ubuntu...

1. Open terminal
sudo -s
apt-get update
2. after installation update finish, we need check the NIC interface
in terminal type = ifconfig
3. after we check and know the name eth0, eth1 or eth 2 in which
port....
4. we must make a brigde, before make a bridge....we must install it first...
in terminal type = # apt-get install iptables ebtables bridge-utils
5. after installation finish, we must assign the ip address
nano/etc/network/interfaces
in this file we must assign like i show below

auto l0
iface l0 inet loopback
auto br0
iface br0 inet static
address 192.168.x.x (ip static for bridge)
netmask 255.255.255.0
gateway 192.168.x.x
dns-nameservers 202.x.x.x
broadcast 192.168.x.255
bridge_ports eth1 eth2
6. Finish install bridge, we must restart the pc

Next step after restart....try ping from the other pc (ping 192.168.x.x) that u set for interfaces br0...
If u get the respon, thats means your bridge setup success...

7. Then go to terminal...
#apt-get install squid3
8. Finish install squid3open terminal
#
nano /etc/squid3/squid.conf

9. then put under "INSERT"

http_port 3128 transparent
acl_badsites dstdomain .facebook.com
acl_directors src 192.168.x.x
acl_goodtimes time MTWHFAS 8:00-16:00
http_access deny badsites goodtimes
http_access allow all
cache_mem 512mb
cache_dir ufs/var/spool/squid3 6000 16 256 maximum_object_size 4096kb

10. Then /etc/init.d/squid3 restart


How to setup transparent proxy??

type at terminal
#ebtables -t broute -A BROUTING -p IPv4 --ip-protocol 6 --ip-destination-port 80 -j redirect --redirect-target ACCEPT
#iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 -j REDIRECT --to-port 3128

Then be sure to give both scripts execute permissions:
#chmod +x /etc/network/if-post-down.d/iptablessave
#chmod +x /etc /network/if-pre-up.d/iptablesload

Next Step we must configure on startup for Network Manager

#nano /etc/NetworkManager/dispatcher.d/01firewall

Then, Paste script below




No comments:

Post a Comment