2005-05-27 02:03:47 +02:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
|
|
|
|
<article id="Shorewall_Squid_Usage">
|
|
|
|
<!--$Id$-->
|
|
|
|
|
|
|
|
<articleinfo>
|
2004-02-14 19:06:39 +01:00
|
|
|
<title>Using Shorewall with Squid</title>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<authorgroup>
|
|
|
|
<author>
|
|
|
|
<firstname>Tom</firstname>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<surname>Eastep</surname>
|
|
|
|
</author>
|
|
|
|
</authorgroup>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-06-01 17:44:32 +02:00
|
|
|
<pubdate>2005-06-01</pubdate>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<copyright>
|
2005-01-28 21:39:23 +01:00
|
|
|
<year>2003-2005</year>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<holder>Thomas M. Eastep</holder>
|
|
|
|
</copyright>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<legalnotice>
|
|
|
|
<para>Permission is granted to copy, distribute and/or modify this
|
|
|
|
document under the terms of the GNU Free Documentation License, Version
|
|
|
|
1.2 or any later version published by the Free Software Foundation; with
|
|
|
|
no Invariant Sections, with no Front-Cover, and with no Back-Cover
|
2005-05-27 02:03:47 +02:00
|
|
|
Texts. A copy of the license is included in the section entitled <quote>
|
|
|
|
<ulink url="GnuCopyright.htm">GNU Free Documentation License</ulink>
|
|
|
|
</quote>.</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
</legalnotice>
|
|
|
|
</articleinfo>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<para>This page covers Shorewall configuration to use with <ulink
|
|
|
|
url="http://www.squid-cache.org">Squid</ulink> running as a Transparent
|
2004-02-14 19:06:39 +01:00
|
|
|
Proxy or as a Manual Proxy.</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-02-28 19:36:46 +01:00
|
|
|
<warning>
|
|
|
|
<para>This documentation assumes that you are running Shorewall 2.0.0 or
|
|
|
|
later.</para>
|
|
|
|
</warning>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<section>
|
|
|
|
<title>Squid as a Transparent Proxy</title>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-10-18 00:34:23 +02:00
|
|
|
<important>
|
|
|
|
<para>This section gives instructions for transparent proxying of HTTP.
|
2005-05-27 02:03:47 +02:00
|
|
|
HTTPS (normally TCP port 443) <emphasis role="bold">cannot</emphasis> be
|
2004-10-18 00:34:23 +02:00
|
|
|
proxied transparently (stop and think about it for a minute; if HTTPS
|
|
|
|
could be transparently proxied, then how secure would it be?).</para>
|
|
|
|
</important>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<caution>
|
|
|
|
<para>Please observe the following general requirements:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>In all cases, Squid should be configured to run as a transrent
|
2005-05-27 02:03:47 +02:00
|
|
|
proxy as described at <ulink
|
|
|
|
url="http://www.tldp.org/HOWTO/mini/TransparentProxy.html">http://www.tldp.org/HOWTO/mini/TransparentProxy.html</ulink>.</para>
|
2005-01-28 21:39:23 +01:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-01-28 21:39:23 +01:00
|
|
|
<listitem>
|
2005-01-29 01:06:20 +01:00
|
|
|
<para>Depending on your distribution, other Squid configuration
|
|
|
|
changes may be required. These changes typically consist of:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-01-29 00:33:01 +01:00
|
|
|
<orderedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>Adding an ACL that represents the clients on your local
|
|
|
|
network.</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-01-29 00:33:01 +01:00
|
|
|
<para>Example:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-01-29 00:33:01 +01:00
|
|
|
<programlisting>ACL my_networks src 192.168.1.0/24 192.168.2.0/24</programlisting>
|
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-01-29 00:33:01 +01:00
|
|
|
<listitem>
|
|
|
|
<para>Allowing HTTP access to that ACL.</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-01-29 00:33:01 +01:00
|
|
|
<para>Example:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-01-29 00:33:01 +01:00
|
|
|
<programlisting>http_access allow my_networks</programlisting>
|
|
|
|
</listitem>
|
|
|
|
</orderedlist>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<para>See your distribution's Squid documenation and <ulink
|
|
|
|
url="http://www.squid-cache.org/">http://www.squid-cache.org/</ulink>
|
2005-01-29 00:33:01 +01:00
|
|
|
for details.</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<para>It is a good idea to get Squid working as a <link
|
|
|
|
linkend="Manual">manual proxy</link> first before you try
|
2005-01-29 01:06:20 +01:00
|
|
|
transparent proxying.</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
|
|
|
<para>The following instructions mention the files
|
2004-10-18 00:34:23 +02:00
|
|
|
/etc/shorewall/start and /etc/shorewall/init -- if you don't have
|
|
|
|
those files, siimply create them.</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
|
|
|
<para>When the Squid server is in the DMZ zone or in the local zone,
|
|
|
|
that zone must be defined ONLY by its interface -- no
|
|
|
|
/etc/shorewall/hosts file entries. That is because the packets being
|
|
|
|
routed to the Squid server still have their original destination IP
|
|
|
|
addresses.</para>
|
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
|
|
|
<para>You must have iptables installed on your Squid server.</para>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</caution>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-07-24 04:52:28 +02:00
|
|
|
<caution>
|
|
|
|
<para>In the instructions below, only TCP Port 80 is opened from the
|
2005-05-27 02:03:47 +02:00
|
|
|
system running Squid to the Internet. If your users require browsing
|
2004-10-18 00:34:23 +02:00
|
|
|
sites that use a port other than 80 (e.g.,
|
2005-05-27 02:03:47 +02:00
|
|
|
http://www.domain.tld:<emphasis role="bold">8080</emphasis>) then you
|
2004-10-18 00:34:23 +02:00
|
|
|
must open those ports as well.</para>
|
2004-07-24 04:52:28 +02:00
|
|
|
</caution>
|
2004-02-14 19:06:39 +01:00
|
|
|
</section>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<section>
|
|
|
|
<title>Configurations</title>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<para>Three different configurations are covered:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<simplelist>
|
|
|
|
<member>Squid (transparent) Running on the Firewall</member>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<member>Squid (transparent) Running in the local Network</member>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<member>Squid (transparent) Running in a DMZ</member>
|
|
|
|
</simplelist>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<section id="Firewall">
|
2004-02-14 19:06:39 +01:00
|
|
|
<title>Squid (transparent) Running on the Firewall</title>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<para>You want to redirect all local www connection requests EXCEPT
|
|
|
|
those to your own http server (206.124.146.177) to a Squid transparent
|
|
|
|
proxy running on the firewall and listening on port 3128. Squid will of
|
|
|
|
course require access to remote web servers.</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<para>In <filename>/etc/shorewall/rules</filename>:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<programlisting>#ACTION SOURCE DEST PROTO DEST PORT(S) SOURCE ORIGINAL
|
|
|
|
# PORT(S) DEST
|
2004-07-15 00:06:35 +02:00
|
|
|
REDIRECT loc 3128 tcp www - !206.124.146.177
|
2004-02-14 19:06:39 +01:00
|
|
|
ACCEPT fw net tcp www</programlisting>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<para>There may be a requirement to exclude additional destination hosts
|
|
|
|
or networks from being redirected. For example, you might also want
|
|
|
|
requests destined for 130.252.100.0/24 to not be routed to Squid.</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-02-28 19:36:46 +01:00
|
|
|
<para>If needed, you may just add the additional hosts/networks to the
|
|
|
|
ORIGINAL DEST column in your REDIRECT rule.</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<para><filename>/etc/shorewall/rules</filename>:<programlisting>#ACTION SOURCE DEST PROTO DEST PORT(S) SOURCE ORIGINAL
|
2004-02-14 19:06:39 +01:00
|
|
|
# PORT(S) DEST
|
2005-05-27 02:03:47 +02:00
|
|
|
REDIRECT loc 3128 tcp www - !206.124.146.177,130.252.100.0/24</programlisting></para>
|
2004-02-14 19:06:39 +01:00
|
|
|
</section>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<section id="Local">
|
2004-02-14 19:06:39 +01:00
|
|
|
<title>Squid (transparent) Running in the local network</title>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<para>You want to redirect all local www connection requests to a Squid
|
|
|
|
transparent proxy running in your local zone at 192.168.1.3 and
|
|
|
|
listening on port 3128. Your local interface is eth1. There may also be
|
|
|
|
a web server running on 192.168.1.3. It is assumed that web access is
|
2005-05-16 03:41:24 +02:00
|
|
|
already enabled from the local zone to the internet.</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-06-01 17:44:32 +02:00
|
|
|
<para>If you are running a Shorewall version earlier than 2.3.2
|
|
|
|
then:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<orderedlist>
|
|
|
|
<listitem>
|
2005-03-01 21:20:26 +01:00
|
|
|
<para>On your firewall system, issue the following command</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<programlisting><command>echo 202 www.out >> /etc/iproute2/rt_tables</command> </programlisting>
|
2004-02-14 19:06:39 +01:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
2005-03-05 17:53:54 +01:00
|
|
|
<para>Create <filename>/etc/shorewall/addroutes</filename> as
|
|
|
|
follows:</para>
|
|
|
|
|
2005-05-27 02:03:47 +02:00
|
|
|
<programlisting><command>#!/bin/sh
|
|
|
|
|
|
|
|
if [ -z "`ip rule list | grep www.out`" ] ; then
|
2005-03-01 21:20:26 +01:00
|
|
|
ip rule add fwmark 0xCA table www.out # Note 0xCA = 202
|
2004-02-14 19:06:39 +01:00
|
|
|
ip route add default via 192.168.1.3 dev eth1 table www.out
|
|
|
|
ip route flush cache
|
2005-05-27 02:03:47 +02:00
|
|
|
echo 0 > /proc/sys/net/ipv4/conf/eth1/send_redirects
|
|
|
|
fi</command> </programlisting>
|
2004-02-14 19:06:39 +01:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
2005-03-05 17:53:54 +01:00
|
|
|
<para>Make <filename>/etc/shorewall/addroutes </filename>executable
|
|
|
|
via:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<programlisting><command>chmod +x /etc/shorewall/addroutes</command> </programlisting>
|
2005-03-05 17:53:54 +01:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-03-05 17:53:54 +01:00
|
|
|
<listitem>
|
|
|
|
<para>In /etc/shorewall/init, put:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<programlisting><command>run_and_save_command "/etc/shorewall/addroutes"</command> </programlisting>
|
2005-03-05 17:53:54 +01:00
|
|
|
</listitem>
|
2005-05-20 16:04:11 +02:00
|
|
|
</orderedlist>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-05-20 16:04:11 +02:00
|
|
|
<para>If you are running Shorewall 2.3.2 or later:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-05-20 16:04:11 +02:00
|
|
|
<orderedlist>
|
2005-05-16 03:41:24 +02:00
|
|
|
<listitem>
|
2005-05-20 16:04:11 +02:00
|
|
|
<para>Add this entry to your /etc/shorewall/providers file.</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-05-20 16:04:11 +02:00
|
|
|
<programlisting>#NAME NUMBER MARK DUPLICATE INTERFACE GATEWAY OPTIONS
|
|
|
|
Squid 1 202 - eth1 192.168.1.3 -</programlisting>
|
2005-05-16 03:41:24 +02:00
|
|
|
</listitem>
|
|
|
|
</orderedlist>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-05-20 16:04:11 +02:00
|
|
|
<para>Regardless of your Shorewall version, you need the
|
|
|
|
following:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-05-20 16:04:11 +02:00
|
|
|
<orderedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>In <filename>/etc/shorewall/start</filename> add:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<programlisting><command>iptables -t mangle -A PREROUTING -i eth1 -s ! 192.168.1.3 -p tcp --dport 80 -j MARK --set-mark 202</command> </programlisting>
|
2005-05-20 16:04:11 +02:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-03-05 17:53:54 +01:00
|
|
|
<listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
<para>In <filename> <filename>/etc/shorewall/interfaces</filename>
|
|
|
|
</filename>:</para>
|
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<programlisting>#ZONE INTERFACE BROADCAST OPTIONS
|
2005-05-27 02:03:47 +02:00
|
|
|
loc eth1 detect <emphasis role="bold">routeback</emphasis> </programlisting>
|
2004-02-14 19:06:39 +01:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
|
|
|
<para>In /etc/shorewall/rules:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<programlisting>#ACTION SOURCE DEST PROTO DEST PORT(S)
|
|
|
|
ACCEPT loc loc tcp www</programlisting>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<orderedlist numeration="loweralpha">
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
2005-05-26 23:53:40 +02:00
|
|
|
<para>Alternatively, you can have the following policy in place
|
2005-02-28 19:36:46 +01:00
|
|
|
of the above rule.</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<para><filename>/etc/shorewall/policy</filename></para>
|
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<programlisting>#SOURCE DESTINATION POLICY
|
|
|
|
loc loc ACCEPT</programlisting>
|
|
|
|
</listitem>
|
|
|
|
</orderedlist>
|
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
|
|
|
<para>On 192.168.1.3, arrange for the following command to be
|
|
|
|
executed after networking has come up</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<programlisting><command>iptables -t nat -A PREROUTING -i eth0 -d ! 192.168.1.3 -p tcp --dport 80 -j REDIRECT --to-ports 3128</command> </programlisting>
|
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<para>If you are running RedHat on the server, you can simply
|
|
|
|
execute the following commands after you have typed the iptables
|
|
|
|
command above:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<programlisting><command>iptables-save > /etc/sysconfig/iptables
|
|
|
|
chkconfig --level 35 iptables on</command> </programlisting>
|
2004-02-14 19:06:39 +01:00
|
|
|
</listitem>
|
|
|
|
</orderedlist>
|
|
|
|
</section>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<section id="DMZ">
|
2004-02-14 19:06:39 +01:00
|
|
|
<title>Squid (transparent) Running in the DMZ</title>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<para>You have a single Linux system in your DMZ with IP address
|
|
|
|
192.0.2.177. You want to run both a web server and Squid on that system.
|
|
|
|
Your DMZ interface is eth1 and your local interface is eth2.</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-06-01 17:44:32 +02:00
|
|
|
<para>If you are running a Shorewall version earlier than 2.3.2
|
|
|
|
then:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<orderedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>On your firewall system, issue the following command</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<programlisting><command>echo 202 www.out >> /etc/iproute2/rt_tables</command> </programlisting>
|
2004-02-14 19:06:39 +01:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
2005-03-05 17:53:54 +01:00
|
|
|
<para>Create <filename>/etc/shorewall/addroutes</filename> as
|
|
|
|
follows:</para>
|
2004-02-14 19:06:39 +01:00
|
|
|
|
2005-05-27 02:03:47 +02:00
|
|
|
<programlisting><command>#!/bin/sh
|
|
|
|
|
|
|
|
if [ -z "`ip rule list | grep www.out`" ] ; then
|
2005-03-01 21:20:26 +01:00
|
|
|
ip rule add fwmark 0xCA table www.out # Note 0xCA = 202
|
2005-03-05 17:53:54 +01:00
|
|
|
ip route add default via 192.168.1.3 dev eth1 table www.out
|
2004-02-14 19:06:39 +01:00
|
|
|
ip route flush cache
|
2005-05-27 02:03:47 +02:00
|
|
|
echo 0 > /proc/sys/net/ipv4/conf/eth1/send_redirects
|
2005-05-26 23:53:40 +02:00
|
|
|
fi</command>
|
|
|
|
</programlisting>
|
2004-02-14 19:06:39 +01:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-03-05 17:53:54 +01:00
|
|
|
<listitem>
|
|
|
|
<para>Make <filename>/etc/shorewall/addroutes</filename> executable
|
|
|
|
via:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<programlisting><command>chmod +x /etc/shorewall/addroutes</command> </programlisting>
|
2005-03-05 17:53:54 +01:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-03-05 17:53:54 +01:00
|
|
|
<listitem>
|
|
|
|
<para>In <filename>/etc/shorewall/init</filename>, put:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<programlisting><command>run_and_save_command "/etc/shorewall/addroutes"</command> </programlisting>
|
2005-03-05 17:53:54 +01:00
|
|
|
</listitem>
|
2005-05-20 16:04:11 +02:00
|
|
|
</orderedlist>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-05-20 16:04:11 +02:00
|
|
|
<para>If you are running Shorewall 2.3.2 or later:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-05-20 16:04:11 +02:00
|
|
|
<orderedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>Add this entry in
|
|
|
|
<filename>/etc/shorewall/providers</filename>:</para>
|
|
|
|
</listitem>
|
|
|
|
</orderedlist>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-05-20 16:04:11 +02:00
|
|
|
<blockquote>
|
|
|
|
<programlisting>#NAME NUMBER MARK DUPLICATE INTERFACE GATEWAY OPTIONS
|
|
|
|
Squid 1 202 - eth1 192.0.2.177 -
|
|
|
|
</programlisting>
|
|
|
|
</blockquote>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-05-20 16:04:11 +02:00
|
|
|
<para>Regardless of your Shorewall version, you need the
|
|
|
|
following:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2005-05-20 16:04:11 +02:00
|
|
|
<orderedlist>
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
<para>Do <emphasis role="bold">one</emphasis> of the
|
2004-10-18 00:34:23 +02:00
|
|
|
following:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<orderedlist numeration="loweralpha">
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
|
|
|
<para>In <filename>/etc/shorewall/start</filename> add</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<programlisting><command>iptables -t mangle -A PREROUTING -i eth2 -p tcp --dport 80 -j MARK --set-mark 202</command> </programlisting>
|
2004-02-14 19:06:39 +01:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
2004-10-18 00:34:23 +02:00
|
|
|
<para>Set MARK_IN_FORWARD_CHAIN=No in
|
|
|
|
<filename>/etc/shorewall/shorewall.conf</filename> and add the
|
|
|
|
following entry in
|
|
|
|
<filename>/etc/shorewall/tcrules</filename>:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<programlisting>#MARK SOURCE DESTINATION PROTOCOL PORT
|
2004-07-16 22:38:59 +02:00
|
|
|
202 eth2 0.0.0.0/0 tcp 80</programlisting>
|
2004-02-14 19:06:39 +01:00
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
2005-02-28 19:36:46 +01:00
|
|
|
<para>Add the following entry in
|
|
|
|
<filename>/etc/shorewall/tcrules</filename>:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<programlisting>#MARK SOURCE DESTINATION PROTOCOL PORT
|
2004-07-16 22:38:59 +02:00
|
|
|
202:P eth2 0.0.0.0/0 tcp 80</programlisting>
|
2004-02-14 19:06:39 +01:00
|
|
|
</listitem>
|
|
|
|
</orderedlist>
|
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
2004-10-18 00:34:23 +02:00
|
|
|
<para>In <filename>/etc/shorewall/rules</filename>, you will
|
|
|
|
need:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<programlisting>#ACTION SOURCE DEST PROTO DEST PORT(S)
|
|
|
|
ACCEPT loc dmz tcp 80
|
|
|
|
ACCEPT dmz net tcp 80</programlisting>
|
|
|
|
</listitem>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<listitem>
|
|
|
|
<para>On 192.0.2.177 (your Web/Squid server), arrange for the
|
|
|
|
following command to be executed after networking has come up</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<programlisting><command>iptables -t nat -A PREROUTING -i eth0 -d ! 192.0.2.177 -p tcp --dport 80 -j REDIRECT --to-ports 3128</command> </programlisting>
|
|
|
|
|
2005-02-28 20:10:27 +01:00
|
|
|
<para>If you are running RedHat/Fedora on the server, you can simply
|
2004-02-14 19:06:39 +01:00
|
|
|
execute the following commands after you have typed the iptables
|
|
|
|
command above:</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<programlisting><command>iptables-save > /etc/sysconfig/iptables
|
|
|
|
chkconfig --level 35 iptables on</command> </programlisting>
|
2004-02-14 19:06:39 +01:00
|
|
|
</listitem>
|
|
|
|
</orderedlist>
|
|
|
|
</section>
|
|
|
|
</section>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<section id="Manual">
|
2004-02-14 19:06:39 +01:00
|
|
|
<title>Squid as a Manual Proxy</title>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<para>Assume that Squid is running in zone SZ and listening on port SP;
|
|
|
|
all web sites that are to be accessed through Squid are in the
|
|
|
|
<quote>net</quote> zone. Then for each zone Z that needs access to the
|
|
|
|
Squid server.</para>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<para><filename>/etc/shorewall/rules</filename>:</para>
|
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<programlisting>#ACTION SOURCE DEST PROTO DEST PORT(S)
|
|
|
|
ACCEPT Z SZ tcp SP
|
2004-07-24 04:52:28 +02:00
|
|
|
ACCEPT SZ net tcp 80,443</programlisting>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
2004-02-14 19:06:39 +01:00
|
|
|
<example>
|
|
|
|
<title>Squid on the firewall listening on port 8080 with access from the
|
|
|
|
<quote>loc</quote> zone:</title>
|
2005-05-27 02:03:47 +02:00
|
|
|
|
|
|
|
<para><filename>/etc/shorewall/rules:</filename> <programlisting>#ACTION SOURCE DEST PROTO DEST PORT(S)
|
2004-02-14 19:06:39 +01:00
|
|
|
ACCEPT loc fw tcp 8080
|
2005-05-27 02:03:47 +02:00
|
|
|
ACCEPT fw net tcp 80,443</programlisting></para>
|
2004-02-14 19:06:39 +01:00
|
|
|
</example>
|
|
|
|
</section>
|
2005-05-27 02:03:47 +02:00
|
|
|
</article>
|