<?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>The Linux Blog &#187; squid</title>
	<atom:link href="http://linuxblog.ro/tag/squid/feed/" rel="self" type="application/rss+xml" />
	<link>http://linuxblog.ro</link>
	<description>UNIX, LINUX, BSD, OSX</description>
	<lastBuildDate>Thu, 19 Aug 2010 14:32:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Squid Proxy Server Mac Address based filtering</title>
		<link>http://linuxblog.ro/squid-proxy-server-mac-address-based-filtering/</link>
		<comments>http://linuxblog.ro/squid-proxy-server-mac-address-based-filtering/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 14:24:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[acces]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[squid]]></category>

		<guid isPermaLink="false">http://linuxblog.ro/?p=362</guid>
		<description><![CDATA[Here is how to setup ACL's based on MAC address squid proxy...
]]></description>
			<content:encoded><![CDATA[<h2>Setting up ACL&#8217;s based on MAC address</h2>
<p>Open squid.conf:<br />
<code># vi /etc/squid/squid.conf</code><br />
Local acl, section and append ACL as follows:<br />
<code>acl macf1 arp mac-address<br />
acl macf2 arp 00:11:22:33:44:55<br />
http_access allow macf1<br />
http_access allow macf2<br />
http_access deny all</code></p>
<p>Save and close the file. Restart squid server:<br />
<code># /etc/init.d/squid restart</code></p>
<p>Thanks to cyberciti.biz</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxblog.ro/squid-proxy-server-mac-address-based-filtering/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transparent proxy with Squid</title>
		<link>http://linuxblog.ro/transparent-proxy-with-squid/</link>
		<comments>http://linuxblog.ro/transparent-proxy-with-squid/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 14:19:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[transparent]]></category>

		<guid isPermaLink="false">http://linuxblog.ro/?p=359</guid>
		<description><![CDATA[First, Squid server installed (use up2date squid) and configured by adding following directives to file:
# vi /etc/squid/squid.conf]]></description>
			<content:encoded><![CDATA[<h3>Server Configuration</h3>
<ul>
<li>Step #1 : Squid configuration so that it will act as a transparent proxy</li>
<li>Step #2 : Iptables configuration
<ul>
<li>a)	Configure system as router</li>
<li>b)	Forward all http requests to 3128 (DNAT)</li>
</ul>
</li>
<li>Step #3: Run scripts and start squid service</li>
</ul>
<p>First, Squid server installed (use up2date squid) and configured by adding following directives to file:<br />
<code># vi /etc/squid/squid.conf</code></p>
<p>Modify or add following squid directives:<br />
<code>httpd_accel_host <span style="color: #ff0000;">virtual</span><br />
httpd_accel_port <span style="color: #ff0000;">80</span><br />
httpd_accel_with_proxy <span style="color: #ff0000;">on</span><br />
httpd_accel_uses_host_header <span style="color: #ff0000;">on</span><br />
acl lan src <span style="color: #ff0000;">192.168.1.1 192.168.2.0/24</span><br />
http_access allow <span style="color: #ff0000;">localhost</span><br />
http_access allow <span style="color: #ff0000;">lan</span></code></p>
<p>Where,</p>
<ul>
<li>httpd_accel_host <span style="color: #ff0000;">virtual</span>: Squid as an httpd accelerator</li>
<li>httpd_accel_port <span style="color: #ff0000;">80</span>: 80 is port you want to act as a proxy</li>
<li>httpd_accel_with_proxy <span style="color: #ff0000;">on</span>: Squid act as both a local httpd accelerator and as a proxy.</li>
<li>httpd_accel_uses_host_header <span style="color: #ff0000;">on</span>: Header is turned on which is the hostname from the URL.</li>
<li>acl lan src <span style="color: #ff0000;">192.168.1.1 192.168.2.0/24</span>: Access control list, only allow LAN computers to use squid</li>
<li>http_access allow <span style="color: #ff0000;">localhost</span>: Squid access to LAN and localhost ACL only</li>
<li>http_access allow <span style="color: #ff0000;">lan</span>: &#8212; same as above &#8211;</li>
</ul>
<p>Here is the complete listing of squid.conf for your reference (grep will remove all comments and sed will remove all empty lines, thanks to David Klein for quick hint ):<br />
<code># grep -v "^#" /etc/squid/squid.conf | sed -e '/^$/d'</code></p>
<p>OR, try out sed (thanks to <a href="http://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html#comment-144">kotnik</a> for small sed trick)<br />
<code># cat /etc/squid/squid.conf | sed '/ *#/d; /^ *$/d'</code></p>
<p>Output:<br />
<code>hierarchy_stoplist cgi-bin ?<br />
acl QUERY urlpath_regex cgi-bin \?<br />
no_cache deny QUERY<br />
hosts_file /etc/hosts<br />
refresh_pattern ^ftp:           1440    20%     10080<br />
refresh_pattern ^gopher:        1440    0%      1440<br />
refresh_pattern .               0       20%     4320<br />
acl all src 0.0.0.0/0.0.0.0<br />
acl manager proto cache_object<br />
acl localhost src 127.0.0.1/255.255.255.255<br />
acl to_localhost dst 127.0.0.0/8<br />
acl purge method PURGE<br />
acl CONNECT method CONNECT<br />
cache_mem 1024 MB<br />
http_access allow manager localhost<br />
http_access deny manager<br />
http_access allow purge localhost<br />
http_access deny purge<br />
http_access deny !Safe_ports<br />
http_access deny CONNECT !SSL_ports<br />
acl lan src 192.168.1.1  192.168.2.0/24<br />
http_access allow localhost<br />
http_access allow lan<br />
http_access deny all<br />
http_reply_access allow all<br />
icp_access allow all<br />
visible_hostname myclient.hostname.com<br />
httpd_accel_host virtual<br />
httpd_accel_port 80<br />
httpd_accel_with_proxy on<br />
httpd_accel_uses_host_header on<br />
coredump_dir /var/spool/squid</code></p>
<h3>Iptables configuration</h3>
<p>Next, I had added following rules to forward all http requests (coming to port 80) to the Squid server port 3128 :<br />
<code>iptables -t nat -A PREROUTING -i  <span style="color: #ff0000;">eth1</span> -p tcp --dport <span style="color: #ff0000;">80</span> -j DNAT --to 192.168.1.1:3128<br />
iptables -t nat -A PREROUTING -i  <span style="color: #ff0000;">eth0</span> -p tcp --dport  <span style="color: #ff0000;">80 -j REDIRECT --to-port 3128</span></code></p>
<p>Here is complete shell script. Script first configure Linux system as router and forwards all http request to port 3128 (Download the <a href="http://www.cyberciti.biz/tips/wp-content/uploads/2006/06/fw.proxy.txt">fw.proxy</a> shell script):<br />
<code><em><span style="color: #9a1900;">#!/bin/sh</span></em><br />
<em><span style="color: #9a1900;"># squid server IP</span></em><br />
SQUID_SERVER<span style="color: #990000;">=</span><span style="color: #ff0000;">"192.168.1.1"</span><br />
<em><span style="color: #9a1900;"># Interface connected to Internet</span></em><br />
INTERNET<span style="color: #990000;">=</span><span style="color: #ff0000;">"eth0"</span><br />
<em><span style="color: #9a1900;"># Interface connected to LAN</span></em><br />
LAN_IN<span style="color: #990000;">=</span><span style="color: #ff0000;">"eth1"</span><br />
<em><span style="color: #9a1900;"># Squid port</span></em><br />
SQUID_PORT<span style="color: #990000;">=</span><span style="color: #ff0000;">"3128"</span><br />
<em><span style="color: #9a1900;"># DO NOT MODIFY BELOW</span></em><br />
<em><span style="color: #9a1900;"># Clean old firewall</span></em><br />
iptables <span style="color: #990000;">-</span>F<br />
iptables <span style="color: #990000;">-</span>X<br />
iptables <span style="color: #990000;">-</span>t nat <span style="color: #990000;">-</span>F<br />
iptables <span style="color: #990000;">-</span>t nat <span style="color: #990000;">-</span>X<br />
iptables <span style="color: #990000;">-</span>t mangle <span style="color: #990000;">-</span>F<br />
iptables <span style="color: #990000;">-</span>t mangle <span style="color: #990000;">-</span>X<br />
<em><span style="color: #9a1900;"># Load IPTABLES modules for NAT and IP conntrack support</span></em><br />
modprobe ip_conntrack<br />
modprobe ip_conntrack_ftp<br />
<em><span style="color: #9a1900;"># For win xp ftp client</span></em><br />
<em><span style="color: #9a1900;">#modprobe ip_nat_ftp</span></em><br />
echo <span style="color: #993399;">1</span> <span style="color: #990000;">&gt;</span> /proc/sys/net/ipv4/<strong><span style="color: #0000ff;">ip_forward</span></strong><br />
<em><span style="color: #9a1900;"># Setting default filter policy</span></em><br />
iptables <span style="color: #990000;">-</span>P INPUT DROP<br />
iptables <span style="color: #990000;">-</span>P OUTPUT ACCEPT<br />
<em><span style="color: #9a1900;"># Unlimited access to loop back</span></em><br />
iptables <span style="color: #990000;">-</span>A INPUT <span style="color: #990000;">-</span>i lo <span style="color: #990000;">-</span>j ACCEPT<br />
iptables <span style="color: #990000;">-</span>A OUTPUT <span style="color: #990000;">-</span>o lo <span style="color: #990000;">-</span>j ACCEPT<br />
<em><span style="color: #9a1900;"># Allow UDP, DNS and Passive FTP</span></em><br />
iptables <span style="color: #990000;">-</span>A INPUT <span style="color: #990000;">-</span>i <span style="color: #009900;">$INTERNET</span> <span style="color: #990000;">-</span><strong><span style="color: #0000ff;">m</span></strong> state <span style="color: #990000;">-</span><span style="color: #990000;">-</span>state ESTABLISHED<span style="color: #990000;">,</span>RELATED <span style="color: #990000;">-</span>j ACCEPT<br />
<em><span style="color: #9a1900;"># set this system as a router for Rest of LAN</span></em><br />
iptables <span style="color: #990000;">-</span><span style="color: #990000;">-</span>table nat <span style="color: #990000;">-</span><span style="color: #990000;">-</span>append POSTROUTING <span style="color: #990000;">-</span><span style="color: #990000;">-</span>out<span style="color: #990000;">-</span>interface <span style="color: #009900;">$INTERNET</span> <span style="color: #990000;">-</span>j MASQUERADE<br />
iptables <span style="color: #990000;">-</span><span style="color: #990000;">-</span>append FORWARD <span style="color: #990000;">-</span><span style="color: #990000;">-</span>in<span style="color: #990000;">-</span>interface <span style="color: #009900;">$LAN_IN</span> <span style="color: #990000;">-</span>j ACCEPT<br />
<em><span style="color: #9a1900;"># unlimited access to LAN</span></em><br />
iptables <span style="color: #990000;">-</span>A INPUT <span style="color: #990000;">-</span>i <span style="color: #009900;">$LAN_IN</span> <span style="color: #990000;">-</span>j ACCEPT<br />
iptables <span style="color: #990000;">-</span>A OUTPUT <span style="color: #990000;">-</span>o <span style="color: #009900;">$LAN_IN</span> <span style="color: #990000;">-</span>j ACCEPT<br />
<em><span style="color: #9a1900;"># DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy</span></em><br />
iptables <span style="color: #990000;">-</span>t nat <span style="color: #990000;">-</span>A PREROUTING <span style="color: #990000;">-</span>i <span style="color: #009900;">$LAN_IN</span> <span style="color: #990000;">-</span>p tcp <span style="color: #990000;">-</span><span style="color: #990000;">-</span>dport <span style="color: #993399;">80</span> <span style="color: #990000;">-</span>j DNAT <span style="color: #990000;">-</span><span style="color: #990000;">-</span>to <span style="color: #009900;">$SQUID_SERVER</span><span style="color: #990000;">:</span><span style="color: #009900;">$SQUID_PORT</span><br />
<em><span style="color: #9a1900;"># if it is same system</span></em><br />
iptables <span style="color: #990000;">-</span>t nat <span style="color: #990000;">-</span>A PREROUTING <span style="color: #990000;">-</span>i <span style="color: #009900;">$INTERNET</span> <span style="color: #990000;">-</span>p tcp <span style="color: #990000;">-</span><span style="color: #990000;">-</span>dport <span style="color: #993399;">80</span> <span style="color: #990000;">-</span>j REDIRECT <span style="color: #990000;">-</span><span style="color: #990000;">-</span>to<span style="color: #990000;">-</span>port <span style="color: #009900;">$SQUID_PORT</span><br />
<em><span style="color: #9a1900;"># DROP everything and Log it</span></em><br />
iptables <span style="color: #990000;">-</span>A INPUT <span style="color: #990000;">-</span>j LOG<br />
iptables <span style="color: #990000;">-</span>A INPUT <span style="color: #990000;">-</span>j DROP</code></p>
<p>Save shell script. Execute script so that system will act as a router and forward the ports:<br />
<code># chmod +x /etc/fw.proxy<br />
# /etc/fw.proxy<br />
# service iptables save<br />
# chkconfig iptables on</code></p>
<p>Start or Restart the squid:<br />
<code># /etc/init.d/squid restart<br />
# chkconfig squid on</code></p>
<h3>Desktop / Client computer configuration</h3>
<p>Point all desktop clients to your eth1 IP address (192.168.2.1) as Router/Gateway (use DHCP to distribute this information). You do not have to setup up individual browsers to work with proxies.</p>
<h3>How do I test my squid proxy is working correctly?</h3>
<p>See access log file /var/log/squid/access.log:<br />
<code># tail -f /var/log/squid/access.log</code></p>
<p>Above command will monitor all incoming request and log them to /var/log/squid/access_log file. Now if somebody accessing a website through browser, squid will log information.</p>
<h3>Problems and solutions</h3>
<h4>(a) Windows XP FTP Client</h4>
<p>All Desktop client FTP session request ended with an error:<br />
Illegal PORT command.</p>
<p>I had loaded the ip_nat_ftp kernel module. Just type the following command press Enter and voila!<br />
<code># modprobe ip_nat_ftp</code></p>
<p>Please note that modprobe command is already added to a shell script (above).</p>
<h4>(b) Port 443 redirection</h4>
<p>I had block out all connection request from our router settings except for our proxy (192.168.1.1) server. So all ports including 443 (https/ssl) request denied. You cannot redirect port 443, from <a href="http://lists.debian.org/debian-user/2004/05/msg01434.html">debian mailing list</a>, &#8220;<em>Long answer: SSL is specifically designed to prevent &#8220;man in the middle&#8221; attacks, and setting up squid in such a way would be the same as such a &#8220;man in the middle&#8221; attack. You might be able to successfully achive this, but not without breaking the encryption and certification that is the point behind SSL</em>&#8220;.</p>
<p>Therefore, I had quickly reopen port 443 (router firewall) for all my LAN computers and problem was solved.</p>
<h4>(c) Squid Proxy authentication in a transparent mode</h4>
<p>You cannot use Squid authentication with a transparently intercepting proxy.</p>
]]></content:encoded>
			<wfw:commentRss>http://linuxblog.ro/transparent-proxy-with-squid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
