<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sohail Riaz, Linux and Open Source Blog &#187; SQUID</title>
	<atom:link href="http://www.sohailriaz.com/category/squid/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sohailriaz.com</link>
	<description>Sohail Riaz, Linux and Open Source Blog</description>
	<lastBuildDate>Sat, 17 Jul 2010 07:38:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How To Bind MAC with IP in SQUID</title>
		<link>http://www.sohailriaz.com/how-to-bind-mac-with-ip-in-squid/</link>
		<comments>http://www.sohailriaz.com/how-to-bind-mac-with-ip-in-squid/#comments</comments>
		<pubDate>Sat, 30 May 2009 07:35:21 +0000</pubDate>
		<dc:creator>Sohail Riaz</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[SQUID]]></category>

		<guid isPermaLink="false">http://www.sohailriaz.com/?p=103</guid>
		<description><![CDATA[<a href="http://www.sohailriaz.com/how-to-bind-mac-with-ip-in-squid/"><img src=""  alt="" title="" /></a>
In this how to i describe how to bind MAC with IP to restrict users in your network to change their IP&#8217;s to bypass filtering. To ease the setup i will create small scripts to simplify our work. Here i will not describe how to config squid and how to run it. I assume you [...]]]></description>
			<content:encoded><![CDATA[<p>In this how to i describe how to bind MAC with IP to restrict users in your network to change their IP&#8217;s to bypass filtering. To ease the setup i will create small scripts to simplify our work. Here i will not describe how to config squid and how to run it. I assume you have already configure it. <span id="more-103"></span></p>
<h3>1) Grep MAC Addresses</h3>
<p>Let suppose we have 10 machines with IPs range 192.168.0.1 &#8211; 192.168.0.10, you have to get mac address for them using following command.</p>
<p>Besure your machines are up and pingable, else you will get empty lines and you have to remove them manually.</p>
<blockquote><p>for i in `seq 1 10`; do ping -c 1 192.168.0.$i; arp -n 192.168.0.$i | grep -v Address | grep -v incomplete | awk &#8216;{print $1 &#8221; &#8220;  $3}&#8217; &gt;&gt; ip-mac.txt; done</p></blockquote>
<p>This command will get required mac address with IP in a file named ip-mac.txt</p>
<blockquote><p>cat ip-mac.txt<br />
192.168.0.1 00:1D:09:6B:3C:28<br />
192.168.0.2 00:1D:09:6A:EA:02<br />
192.168.0.3 00:1D:09:71:2C:34<br />
192.168.0.4 00:1D:09:6A:CB:85<br />
192.168.0.5 00:1D:09:6A:C3:15<br />
192.168.0.6 00:1D:09:6A:CA:8B<br />
192.168.0.7 00:1D:09:6A:CB:DA<br />
192.168.0.8 00:1D:09:6A:CC:34<br />
192.168.0.9 00:1D:09:6B:11:76<br />
192.168.0.10 00:1D:09:6B:36:6F</p></blockquote>
<h3>2) Create ACL For SQUID.</h3>
<p>I will create a small bash script to easy my work.</p>
<p>To get acl for mac</p>
<blockquote><p>i=1<br />
cat ip-mac.txt | while read a; do b=`echo $a | cut -f 2 -d &#8221; &#8220;`; echo &#8220;acl mac$i arp $b&#8221; &gt;&gt; squid-mac-filter.txt; i=`expr $i + 1`; done</p></blockquote>
<blockquote><p>cat squid-mac-filter.txt<br />
acl mac1 arp 00:1D:09:6B:3C:28<br />
acl mac2 arp 00:1D:09:6A:EA:02<br />
acl mac3 arp 00:1D:09:71:2C:34<br />
acl mac4 arp 00:1D:09:6A:CB:85<br />
acl mac5 arp 00:1D:09:6A:C3:15<br />
acl mac6 arp 00:1D:09:6A:CA:8B<br />
acl mac7 arp 00:1D:09:6A:CB:DA<br />
acl mac8 arp 00:1D:09:6A:CC:34<br />
acl mac9 arp 00:1D:09:6B:11:76<br />
acl mac10 arp 00:1D:09:6B:36:6F</p></blockquote>
<p>To get acl for ip</p>
<blockquote><p>i=1<br />
cat ip-mac.txt | while read a; do b=`echo $a | cut -f 1 -d &#8221; &#8220;`; echo &#8220;acl ip$i src $b&#8221; &gt;&gt; squid-ip-filter.txt; i=`expr $i + 1`; done</p></blockquote>
<blockquote><p>cat squid-ip-filter.txt<br />
acl ip1 arp 192.168.0.1<br />
acl ip2 arp 192.168.0.2<br />
acl ip3 arp 192.168.0.3<br />
acl ip4 arp 192.168.0.4<br />
acl ip5 arp 192.168.0.5<br />
acl ip6 arp 192.168.0.6<br />
acl ip7 arp 192.168.0.7<br />
acl ip8 arp 192.168.0.8<br />
acl ip9 arp 192.168.0.9<br />
acl ip10 arp 192.168.0.10</p></blockquote>
<p>To generate http_access allow lines, you have to get the max number of your list of IP&#8217;s and MAC&#8217;s. Here i have is 10, sure both will be the same <img src='http://www.sohailriaz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<blockquote><p>for i in `seq 1 10`; do echo &#8220;http_access allow mac$i ip$i&#8221; &gt;&gt; http-access-squid.txt; done</p></blockquote>
<blockquote><p>cat http-access-squid.txt<br />
http_access allow mac1 ip1<br />
http_access allow mac2 ip2<br />
http_access allow mac3 ip3<br />
http_access allow mac4 ip4<br />
http_access allow mac5 ip5<br />
http_access allow mac6 ip6<br />
http_access allow mac7 ip7<br />
http_access allow mac8 ip8<br />
http_access allow mac9 ip9<br />
http_access allow mac10 ip10</p></blockquote>
<p>Now concatinate three files i.e squid-ip-filter.txt, squid-mac-filter.txt and http_access_squid.txt</p>
<blockquote><p>cat squid-mac-filter.txt squid-ip-filter.txt http-access-squid.txt &gt;&gt; acl-final.txt</p></blockquote>
<p>and copy from acl-final.txt to paste on appropriate location in squid.conf, dont forget to put http_access deny all on the last <img src='http://www.sohailriaz.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>To get more help on it please use comments.</p>
<img src="http://www.sohailriaz.com/wp-content/plugins/pixelstats/trackingpixel.php?post_id=103&amp;ts=1284150094" style="display:none;" alt="pixelstats trackingpixel"/>]]></content:encoded>
			<wfw:commentRss>http://www.sohailriaz.com/how-to-bind-mac-with-ip-in-squid/feed/</wfw:commentRss>
		<slash:comments>77</slash:comments>
		</item>
		<item>
		<title>Anonymous Proxy using SQUID 3</title>
		<link>http://www.sohailriaz.com/anonymous-proxy-using-squid-3/</link>
		<comments>http://www.sohailriaz.com/anonymous-proxy-using-squid-3/#comments</comments>
		<pubDate>Sat, 15 Nov 2008 12:06:54 +0000</pubDate>
		<dc:creator>Sohail Riaz</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[SQUID]]></category>

		<guid isPermaLink="false">http://www.sohailriaz.com/?p=16</guid>
		<description><![CDATA[<a href="http://www.sohailriaz.com/anonymous-proxy-using-squid-3/"><img src=""  alt="" title="" /></a>
This howto describe step by step method to install SQUID 3 server as Anonymous Proxy. An anonymous proxy is a tool that attempts to make activity on the Internet untraceable. It accesses the Internet on the user&#8217;s behalf, protecting personal information by hiding the source computer&#8217;s identifying information. Simply say to hide your IP.The following [...]]]></description>
			<content:encoded><![CDATA[<p>This howto describe step by step method to install SQUID 3 server as Anonymous Proxy. An anonymous proxy is a tool that attempts to make activity on the Internet untraceable. It accesses the Internet on the user&#8217;s behalf, protecting personal information by hiding the source computer&#8217;s identifying information. Simply say to hide your IP.<span id="more-16"></span>The following How To setups CentOS 5 as OS but it can be implemented on CentOS 4, Fedora Core 5-9 with same steps and SQUID version 3. Bydefault SQUID only uses default IP to communicate on internet but we will make use of all IPs available on server to act as anonymous proxy i.e if user connects to IP1 of server then IP1 will be act as proxy and forward same IP, if user connects to IP2 then IP2 will be act proxy and foward same IP and so on and also we will implement ncsa user based authentication to protect server from unauthorized used.</p>
<p>Server = CentOS 5.2, SQUID = version 3, IPs = 192.168.0.1 &#8211; 192.168.0.5</p>
<h3>1 Installation Of Squid 3:</h3>
<p>CentOS 5 comes with SQUID 2.6 but we need squid 3, so we will download source rpm of squid 3 and compile for our OS.</p>
<h3>1.1  Install Pre-requisite</h3>
<p>Install pre-requisite softwares i.e Development Tools to get all the compilers, libraries and other rpms for compilation of SQUID 3.</p>
<blockquote><p>yum -y groupinstall &#8220;Development Tools&#8221;<br />
yum -y install rpm-build openjade linuxdoc-tools openldap-devel pam-devel openssl-devel httpd rpm-devel</p></blockquote>
<h3>1.2 Download Squid 3 Source RPM</h3>
<p>Download source rpm of Squid 3 from FEDORA website and install it.</p>
<blockquote><p>cd /usr/src<br />
wget http://download.fedora.redhat.com/pub/fedora/linux/releases/10/Fedora/source/SRPMS/squid-3.0.STABLE10-1.fc10.src.rpm<br />
rpm -ivh squid-3.0.STABLE10-1.fc10.src.rpm</p></blockquote>
<h3>1.3 Compile Squid 3</h3>
<p>Use following commands to start compilation, at end it will generate rpm file to install</p>
<blockquote><p>cd /usr/src/redhat/SPECS<br />
rpmbuild -bb squid.spec</p></blockquote>
<h3>1.4 Install Squid 3</h3>
<p>Install newly build rpm, which will be found in /usr/src/redhat/RPMS/i386 for i686 and /usr/src/redhat/RPMS/x86_64 for x86_64.</p>
<blockquote><p>rpm -Uvh /usr/src/redhat/RPMS/i386/squid-3.0.STABLE10-1.i386.rpm</p></blockquote>
<h3>2 Configuration</h3>
<p>I will use default squid.conf to edit.</p>
<blockquote><p>vi /etc/squid/squid.conf</p></blockquote>
<h3>2.1 Configure auth_param</h3>
<p>We will enable ncsa authentication to access our squid server. Find following lines</p>
<blockquote><p>#auth_param basic program &lt;uncomment and complete this line&gt;<br />
#auth_param basic childred 5<br />
#auth_param basic realm Squid proxy-caching web server<br />
#auth_param basic credentialsttl 2 hours</p></blockquote>
<p>Change to</p>
<blockquote><p>auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd<br />
auth_param basic childred 5<br />
auth_param basic realm Squid proxy-caching web server<br />
auth_param basic credentialsttl 2 hours</p></blockquote>
<h3>2.2 Create proxy_auth acl</h3>
<p>Here we will create proxy_auth acl to prompt user/pass to everyone want to use anonymous proxy. Find following line</p>
<blockquote><p>#INSERT YOUR OWN RULES(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS</p></blockquote>
<p>We will insert our proxy_auth rule under above line.</p>
<blockquote><p>#INSERT YOUR OWN RULES(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS<br />
acl ncsaauth proxy_auth REQUIRED<br />
http_access allow ncsaauth</p></blockquote>
<h3>2.3 Disable Forwarded Client IP</h3>
<p>Bydefault squid forward client IP to respective website, but to setup anonymous proxy we will disable it to hide client IPs and send only IPs which are configured on squid server. Find following line squid.conf</p>
<blockquote><p>forwarded_for on</p></blockquote>
<p>Change to</p>
<blockquote><p>forwarded_for off</p></blockquote>
<h3>2.4 Configure IPs</h3>
<p>Now we will generate rules for outgoing IP i.e if any one connects to any IP of my server, so it will go with same IP to destination server. In this way we can connect several clients on different IPs and all IPs act as anonymous proxy. Find following line</p>
<blockquote><p># TAG: tcp_outgoing_address</p></blockquote>
<p>add following lines under it.</p>
<blockquote><p>acl ip1 myip 192.168.0.1<br />
tcp_outgoing_address 192.168.0.1 ip1<br />
acl ip2 myip 192.168.0.2<br />
tcp_outgoing_address 192.168.0.2 ip2<br />
acl ip3 myip 192.168.0.3<br />
tcp_outgoing_address 192.168.0.4 ip3<br />
acl ip4 myip 192.168.0.4<br />
tcp_outgoing_address 192.168.0.4 ip4<br />
acl ip5 myip 192.168.0.5<br />
tcp_outgoing_address 192.168.0.5 ip5</p></blockquote>
<p>You can add as many IPs you like, just use the same pattern above.</p>
<h3>2.5 Enable Anonymizer (Anonymous Proxy)</h3>
<p>Put following lines at the bottom of your squid.conf</p>
<blockquote><p>request_header_access Allow allow all<br />
request_header_access Authorization allow all<br />
request_header_access WWW-Authenticate allow all<br />
request_header_access Proxy-Authorization allow all<br />
request_header_access Proxy-Authenticate allow all<br />
request_header_access Cache-Control allow all<br />
request_header_access Content-Encoding allow all<br />
request_header_access Content-Length allow all<br />
request_header_access Content-Type allow all<br />
request_header_access Date allow all<br />
request_header_access Expires allow all<br />
request_header_access Host allow all<br />
request_header_access If-Modified-Since allow all<br />
request_header_access Last-Modified allow all<br />
request_header_access Location allow all<br />
request_header_access Pragma allow all<br />
request_header_access Accept allow all<br />
request_header_access Accept-Charset allow all<br />
request_header_access Accept-Encoding allow all<br />
request_header_access Accept-Language allow all<br />
request_header_access Content-Language allow all<br />
request_header_access Mime-Version allow all<br />
request_header_access Retry-After allow all<br />
request_header_access Title allow all<br />
request_header_access Connection allow all<br />
request_header_access Proxy-Connection allow all<br />
request_header_access User-Agent allow all<br />
request_header_access Cookie allow all<br />
request_header_access All deny all</p></blockquote>
<p>Configuration is finished, save the file.</p>
<h3>3 User Management</h3>
<p>Now its time to create squid_passwd file, in which we will put our users for authentication using ncsa. For this we need htpasswd command to generate user/pass.</p>
<p>create file to hold username and password</p>
<blockquote><p>touch /etc/squid/squid_passwd</p></blockquote>
<h3>3.1 Create New User</h3>
<blockquote><p>htpasswd /etc/squid/squid_passwd proxyadmin</p></blockquote>
<p>Where /etc/squid/squid_passwd is a file, in which all users goes and proxyadmin is a username which will be added with the password given</p>
<h3>4 Service Management</h3>
<p>Run the squid service and add it up at startup.</p>
<blockquote><p>service squid start<br />
chkconfig squid on</p></blockquote>
<h3>5 Troubleshooting</h3>
<h3>5.1 visible_hostname error</h3>
<p>If you see visible_hostname error after starting service, then again edit /etc/squid/squid.conf file and give visible_hostname tag with your server hostname.</p>
<blockquote><p>visible_hostname server1</p></blockquote>
<p>Your server is ready now and you can use Firefox or IExplorer on your client to check its working. I have used default port 3128 for squid, so put any of the above IP and port to connect. As it connects it will prompt you for user/pass, give the right user/pass and you will start browsing the site. To check the anonymity open http://www.whatsmyipaddress.com. If you have done anything wrong in request_header_access, you proxy can be dedect but if everything is fine. It will just show IP and assume its a direct connection without proxy.</p>
<img src="http://www.sohailriaz.com/wp-content/plugins/pixelstats/trackingpixel.php?post_id=16&amp;ts=1284150094" style="display:none;" alt="pixelstats trackingpixel"/>]]></content:encoded>
			<wfw:commentRss>http://www.sohailriaz.com/anonymous-proxy-using-squid-3/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
