<?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>TuxGuides.com &#187; tomato</title>
	<atom:link href="http://www.tuxguides.com/tag/tomato/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tuxguides.com</link>
	<description>Linux Guides &#38; Reviews</description>
	<lastBuildDate>Wed, 19 May 2010 14:43:16 +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>Using Squid with DDWRT</title>
		<link>http://www.tuxguides.com/using-squid-with-ddwrt/</link>
		<comments>http://www.tuxguides.com/using-squid-with-ddwrt/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 03:40:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ddwrt]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[tomato]]></category>

		<guid isPermaLink="false">http://www.tuxguides.com/?p=178</guid>
		<description><![CDATA[Squid has several different uses.  It is a proxy for internet connections.  It can be used to speed up the internet by caching commonly used pages/images to speed up page load times, and decrease bandwidth usage.  It can also be used to filter Internet connections (remove ads or block bad webpages) by configuring and adding [...]]]></description>
			<content:encoded><![CDATA[<p>Squid has several different uses.  It is a proxy for internet connections.  It can be used to speed up the internet by caching commonly used pages/images to speed up page load times, and decrease bandwidth usage.  It can also be used to filter Internet connections (remove ads or block bad webpages) by configuring and adding plugins to it.</p>
<p>In this particular case, I am going to be focusing on how to setup and use Squid with your router running the open source firmware, ddwrt (also confirmed to work on tomato firmware mods).</p>
<h2>Configuring Squid:</h2>
<p>You are going to need a computer that is either on 24/7 or one that is on whenever you need access to the internet.  I have a server running at my house that is always on, so I decided to use that.  I am running ubuntu on my server, so my instructions will be specific to that, but if you are running a different distribution of Linux, you should be able to easily figure out what what commands you will need to use in order to install and configure squid.<span id="more-178"></span></p>
<p><code>sudo apt-get install squid</code></p>
<p>Then, you need to configure the software to allow transparent proxying (forcing users to use the proxy by channeling all http traffic going through the router to go through the squid proxy).  If you do not want to force all users to use a transparent proxy, skip the following sections, and use the section at the end that explains how to use the proxy by configuring your browser.</p>
<p><code>sudo nano /etc/squid/squid.conf</code></p>
<p>edit:</p>
<p><code>http_port 3128</code></p>
<p>to read:</p>
<p><code>http_port 3128 transparent</code></p>
<h2>Configuring DDWRT:</h2>
<p>First, you need to enable ssh on your router to allow you to edit some commands (see the guide <a href="http://www.dd-wrt.com/wiki/index.php/Telnet/SSH_and_the_Command_Line" target="_blank">here</a> or <a href="http://www.dd-wrt.com/wiki/index.php/Telnet/SSH_and_the_Command_Line#Password_Login_method" target="_blank">here</a>).</p>
<p>Next, you need to create and run a script (or you can add this as a startup script for ddwrt).  Make sure you edit the four variables in lines 2-5:</p>
<p><code>#!/bin/sh<br />
INTERNAL_NETWORK=\"192.168.69.0/24\"<br />
ROUTER_IP=\"192.168.69.1\"<br />
PROXY_SERVER=\"192.168.69.123\"<br />
PROXY_PORT=\"3128\"<br />
if [ -z $TRANSPARENT_PROXY ]; then<br />
/usr/sbin/iptables -t nat -A PREROUTING -i br0 -s $INTERNAL_NETWORK -d $INTERNAL_NETWORK -p tcp --dport 80 -j ACCEPT<br />
/usr/sbin/iptables -t nat -A PREROUTING -i br0 -s ! $PROXY_SERVER -p tcp --dport 80 -j DNAT --to $PROXY_SERVER:$PROXY_PORT<br />
/usr/sbin/iptables -t nat -A POSTROUTING -o br0 -s $INTERNAL_NETWORK -p tcp -d $PROXY_SERVER -j SNAT --to $ROUTER_IP<br />
/usr/sbin/iptables -t filter -I FORWARD -s $INTERNAL_NETWORK -d $PROXY_SERVER -i br0 -o br0 -p tcp --dport $PROXY_PORT -j ACCEPT<br />
export TRANSPARENT_PROXY=\"1\"<br />
else<br />
echo \"This script has already run!\"<br />
echo \"If it hasn't, unset \$TRANSPARENT_PROXY manually via the shell.\"<br />
fi</code></p>
<p>If you created this as a startup script for ddwrt, you now need to restart your router in order for it to work.  If you created it as a script, you can simply run the script to enable the transparent proxy.  This script will have to be recreated and run every time you restart the router, so  it is recommended that you set it up as a startup script once you get it working.</p>
<p>If you ever need to disable the proxy, just create and run the following script:</p>
<p><code>#!/bin/sh<br />
INTERNAL_NETWORK=\"192.168.69.0/24\"<br />
ROUTER_IP=\"192.168.69.1\"<br />
PROXY_SERVER=\"192.168.69.123\"<br />
PROXY_PORT=\"3128\"<br />
if [ -z $TRANSPARENT_PROXY ]; then<br />
/usr/sbin/iptables -t nat -D PREROUTING -i br0 -s $INTERNAL_NETWORK -d $INTERNAL_NETWORK -p tcp --dport 80 -j ACCEPT<br />
/usr/sbin/iptables -t nat -D PREROUTING -i br0 -s ! $PROXY_SERVER -p tcp --dport 80 -j DNAT --to $PROXY_SERVER:$PROXY_PORT<br />
/usr/sbin/iptables -t nat -D POSTROUTING -o br0 -s $INTERNAL_NETWORK -p tcp -d $PROXY_SERVER -j SNAT --to $ROUTER_IP<br />
/usr/sbin/iptables -t filter -D FORWARD -s $INTERNAL_NETWORK -d $PROXY_SERVER -i br0 -o br0 -p tcp --dport $PROXY_PORT -j ACCEPT<br />
export TRANSPARENT_PROXY=\"1\"<br />
else<br />
echo \"This script has already run!\"<br />
echo \"If it hasn't, unset \$TRANSPARENT_PROXY manually via the shell.\"<br />
fi</code></p>
<p>If you have any issues with getting this to work, please post in the comments section, and I will do my best to help you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tuxguides.com/using-squid-with-ddwrt/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
