Syed Jahanzaib Personal Blog to Share Knowledge !

October 7, 2010

How To Install Squid in Ubuntu Linux

Filed under: Linux Related — Syed Jahanzaib / Pinochio~:) @ 7:40 AM


How To Install Squid in Ubuntu Linux

1. Install & Configure Squid

First login as root.

a) Then install squid:

apt-get install squid

b) configure:

* gedit /etc/squid/squid.conf
o change squid port: from http_port 3128 to http_port 8080

o find the http_access section, uncomment the following 2 lines and add your own networks (for example

acl our_networks src
http_access allow our_networks

o change hostname in the visible_hostname section after:

#Default: # none hota hay, just add:
visible_hostname localhost # or any other valid hostaname

c) restart squid:

service squid restart

Configure Squid as Transparent Proxy (Squid version >= 2.6)

* gedit /etc/squid/squid.conf

o change from: http_port 3128 to,
http_port 3128 transparent

o add line:
always_direct allow all

* add this line to iptables:

o iptables -t nat -A PREROUTING -i eth0 -p tcp – -dport 80 -d ! -j REDIRECT – -to-port 3128

+ + -i eth0 – adjust to the interface where it will be listening
+ + -d ! – excludes this address range from caching

* save the new iptables:


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: