Sophie

Sophie

distrib > Mandriva > mes5 > x86_64 > by-pkgid > 45723c51178a73df679c2a8284d8eeff > files > 197

shorewall-doc-4.0.15-0.2mdvmes5.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Basic Two-Interface Firewall</title><link rel="stylesheet" href="html.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /></head><body><div class="article" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="two-interface"></a>Basic Two-Interface Firewall</h2></div><div><div class="author"><h3 class="author"><span class="firstname">Tom</span> <span class="surname">Eastep</span></h3></div></div><div><p class="copyright">Copyright © 2002-2007 Thomas M. Eastep</p></div><div><div class="legalnotice"><a id="id279236"></a><p>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
      Texts. A copy of the license is included in the section entitled
      “<span class="quote"><a class="ulink" href="GnuCopyright.htm" target="_self">GNU Free Documentation
      License</a></span>”.</p></div></div><div><p class="pubdate">2008/12/15</p></div></div><hr /></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="#Intro">Introduction</a></span></dt><dd><dl><dt><span class="section"><a href="#System">System Requirements</a></span></dt><dt><span class="section"><a href="#Conventions">Conventions</a></span></dt></dl></dd><dt><span class="section"><a href="#PPTP">PPTP/ADSL</a></span></dt><dt><span class="section"><a href="#Concepts">Shorewall Concepts</a></span></dt><dt><span class="section"><a href="#Interfaces">Network Interfaces</a></span></dt><dt><span class="section"><a href="#Addresses">IP Addresses</a></span></dt><dt><span class="section"><a href="#SNAT">IP Masquerading (SNAT)</a></span></dt><dt><span class="section"><a href="#DNAT">Port Forwarding (DNAT)</a></span></dt><dt><span class="section"><a href="#DNS">Domain Name Server (DNS)</a></span></dt><dt><span class="section"><a href="#Open">Other Connections</a></span></dt><dt><span class="section"><a href="#Logging">Logging</a></span></dt><dt><span class="section"><a href="#Other">Some Things to Keep in Mind</a></span></dt><dt><span class="section"><a href="#Starting">Starting and Stopping Your Firewall</a></span></dt><dt><span class="section"><a href="#Trouble">If it Doesn't Work</a></span></dt><dt><span class="section"><a href="#Reading">Additional Recommended Reading</a></span></dt><dt><span class="section"><a href="#Wireless">Adding a Wireless Segment to your Two-Interface Firewall</a></span></dt></dl></div><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p><span class="bold"><strong>This article applies to Shorewall 4.0 and
    later. If you are running a version of Shorewall earlier than Shorewall
    4.0.0 then please see the documentation for that
    release.</strong></span></p></div><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p><span class="bold"><strong>Do not attempt to install Shorewall on a
    remote system. You are virtually assured to lock yourself out of that
    system.</strong></span></p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Intro"></a>Introduction</h2></div></div></div><p>Setting up a Linux system as a firewall for a small network is a
    fairly straight-forward task if you understand the basics and follow the
    documentation.</p><p>This guide doesn't attempt to acquaint you with all of the features
    of Shorewall. It rather focuses on what is required to configure Shorewall
    in its most common configuration:</p><div class="itemizedlist"><ul type="bullet" compact="compact"><li style="list-style-type: disc"><p>Linux system used as a firewall/router for a small local
        network.</p></li><li style="list-style-type: disc"><p><span class="bold"><strong>Single public IP address.</strong></span> If
        you have more than one public IP address, this is not the guide you
        want -- see the <a class="ulink" href="shorewall_setup_guide.htm" target="_self">Shorewall Setup
        Guide</a> instead.</p></li><li style="list-style-type: disc"><p>Internet connection through cable modem, DSL, ISDN, Frame Relay,
        dial-up ...</p></li></ul></div><p>Here is a schematic of a typical installation: </p><div class="figure"><a id="Figure1"></a><p class="title"><b>Figure 1. Common two interface firewall configuration</b></p><div class="figure-contents"><div class="mediaobject" align="center"><img src="images/basics.png" align="middle" alt="Common two interface firewall configuration" /></div></div></div><p><br class="figure-break" /> </p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>If you edit your configuration files on a
        <span class="trademark">Windows</span>™ system, you must save them as
        <span class="trademark">Unix</span>™ files if your editor supports that option
        or you must run them through <span class="command"><strong>dos2unix</strong></span> before trying
        to use them. Similarly, if you copy a configuration file from your
        <span class="trademark">Windows</span>™ hard drive to a floppy disk, you must
        run <span class="command"><strong>dos2unix</strong></span> against the copy before using it with
        Shorewall. </p><div class="itemizedlist"><ul type="disc"><li><p><a class="ulink" href="http://www.simtel.net/pub/pd/51438.html" target="_self"><span class="trademark">Windows</span>™
              Version of <span class="command"><strong>dos2unix</strong></span></a></p></li><li><p><a class="ulink" href="http://www.megaloman.com/%7Ehany/software/hd2u/" target="_self">Linux
              Version of <span class="command"><strong>dos2unix</strong></span></a></p></li></ul></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="System"></a>System Requirements</h3></div></div></div><p>Shorewall requires that you have the
      <span class="command"><strong>iproute</strong></span>/<span class="command"><strong>iproute2</strong></span> package installed
      (on <span class="trademark">RedHat</span>™, the package is called
      <span class="command"><strong>iproute</strong></span>). You can tell if this package is installed
      by the presence of an <span class="command"><strong>ip</strong></span> program on your firewall
      system. As <code class="systemitem">root</code>, you can use
      the <span class="command"><strong>which</strong></span> command to check for this program:
      </p><pre class="programlisting">[root@gateway root]# <span class="command"><strong>which ip</strong></span>
/sbin/ip
[root@gateway root]#</pre><p> I recommend that you first read through
      the guide to familiarize yourself with what's involved then go back
      through it again making your configuration changes.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="Conventions"></a>Conventions</h3></div></div></div><p>Points at which configuration changes are recommended are flagged
      with <img src="images/BD21298_.gif" />.</p><p>Configuration notes that are unique to LEAF/Bering are marked with
      <img src="images/leaflogo.gif" />.</p></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="PPTP"></a>PPTP/ADSL</h2></div></div></div><p><img src="images/BD21298_.gif" /></p><p>If you have an <acronym class="acronym">ADSL</acronym> Modem and you use
    <acronym class="acronym">PPTP</acronym> to communicate with a server in that modem, you
    must make the changes recommended <a class="ulink" href="PPTP.htm#PPTP_ADSL" target="_self">here</a> in addition to those detailed below.
    <acronym class="acronym">ADSL</acronym> with <acronym class="acronym">PPTP</acronym> is most commonly
    found in Europe, notably in Austria.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Concepts"></a>Shorewall Concepts</h2></div></div></div><p></p><p>The configuration files for Shorewall are contained in the directory
    <code class="filename">/etc/shorewall</code> -- for simple
    setups, you will only need to deal with a few of these as described in
    this guide.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><span class="bold"><strong>Note to Debian and Ubuntu
        Users</strong></span></p><p>If you install using the .deb, you will find that your <code class="filename">/etc/shorewall</code> directory is empty. This
        is intentional. The released configuration file skeletons may be found
        on your system in the directory <code class="filename">/usr/share/doc/shorewall-common/default-config</code>.
        Simply copy the files you need from that directory to <code class="filename">/etc/shorewall</code> and modify the
        copies.</p></div><p><img src="images/BD21298_.gif" /></p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>After you have <a class="ulink" href="Install.htm" target="_self">installed
        Shorewall</a>, locate the two-interfaces samples:</p><div class="orderedlist"><ol type="1"><li><p>If you installed using an RPM, the samples will be in the
            Samples/two-interfaces/ subdirectory of the Shorewall
            documentation directory. If you don't know where the Shorewall
            documentation directory is, you can find the samples using this
            command:</p><pre class="programlisting">~# rpm -ql shorewall-common | fgrep two-interfaces
/usr/share/doc/packages/shorewall/Samples/two-interfaces
/usr/share/doc/packages/shorewall/Samples/two-interfaces/interfaces
/usr/share/doc/packages/shorewall/Samples/two-interfaces/masq
/usr/share/doc/packages/shorewall/Samples/two-interfaces/policy
/usr/share/doc/packages/shorewall/Samples/two-interfaces/routestopped
/usr/share/doc/packages/shorewall/Samples/two-interfaces/rules
/usr/share/doc/packages/shorewall/Samples/two-interfaces/zones
~#</pre></li><li><p>If you installed using the tarball, the samples are in the
            Samples/two-interfaces directory in the tarball.</p></li><li><p>If you installed using a Shorewall 3.x .deb, the samples are
            in /usr/share/doc/shorewall/examples/two-interfaces. You must
            install the shorewall-doc package.</p></li><li><p>If you installed using a Shorewall 4.x .deb, the samples are
            in <code class="filename">/usr/share/doc/shorewall-common/examples/two-interfaces</code>..
            You do not need the shorewall-doc package to have access to the
            samples.</p></li></ol></div></div><p>If you are installing Shorewall version 3.4.0 or later then as each
    file is introduced, I suggest that you look at the actual file on your
    system and that you look at the <a class="ulink" href="configuration_file_basics.htm#Manpages" target="_self">man page</a> for that
    file. For example, to look at the man page for the
    <code class="filename">/etc/shorewall/zones</code> file, type <span class="command"><strong>man
    shorewall-zones</strong></span> at a shell prompt.</p><p>If you are installing a Shorewall version earlier than 3.4.0, then
    as each file is introduced, I suggest that you look through the actual
    file on your system -- each file contains detailed configuration
    instructions and default entries.</p><p>Shorewall views the network where it is running as being composed of
    a set of zones. In the two-interface sample configuration, the following
    zone names are used:</p><pre class="programlisting">#ZONE   TYPE     OPTIONS                 IN                      OUT
#                                        OPTIONS                 OPTIONS
fw      firewall
net     ipv4
loc     ipv4</pre><p>Zones are defined in the <a class="ulink" href="manpages/shorewall-zones.html" target="_self"><code class="filename">/etc/shorewall/</code><code class="filename">zones</code></a>
    file.</p><p>Note that Shorewall recognizes the firewall system as its own zone -
    when the /etc/shorewall/zones file is processed, the name of the firewall
    zone is stored in the shell variable $FW which may be used to refer to the
    firewall zone throughout the Shorewall configuration.</p><p>Rules about what traffic to allow and what traffic to deny are
    expressed in terms of zones. </p><div class="itemizedlist"><ul type="disc" compact="compact"><li><p>You express your default policy for connections from one zone
          to another zone in the <a class="ulink" href="manpages/shorewall-policy.html" target="_self"><code class="filename">/etc/shorewall/</code><code class="filename">policy</code></a>
          file.</p></li><li><p>You define exceptions to those default policies in the <a class="ulink" href="manpages/shorewall-rules.html" target="_self"><code class="filename">/etc/shorewall/</code><code class="filename">rules</code></a>
          file.</p></li></ul></div><p> For each connection request entering the firewall, the
    request is first checked against the <code class="filename">/etc/shorewall/</code><code class="filename">rules</code>
    file. If no rule in that file matches the connection request then the
    first policy in <code class="filename">/etc/shorewall/</code><code class="filename">policy</code>
    that matches the request is applied. If there is a <a class="ulink" href="shorewall_extension_scripts.htm" target="_self">common action</a> defined for the
    policy in <code class="filename">/etc/shorewall/actions</code> or
    <code class="filename">/usr/share/shorewall/actions.std</code> then that action is
    performed before the action is applied. The purpose of the common action is
    two-fold:</p><div class="itemizedlist"><ul type="disc"><li><p>It silently drops or rejects harmless common traffic that would
        otherwise clutter up your log — Broadcasts for example.</p></li><li><p>If ensures that traffic critical to correct operation is allowed
        through the firewall — ICMP <span class="emphasis"><em>fragmentation-needed</em></span>
        for example.</p></li></ul></div><p>The <code class="filename">/etc/shorewall/</code><code class="filename">policy</code>
    file included with the two-interface sample has the following policies:
    </p><pre class="programlisting">#SOURCE    DEST        POLICY      LOG LEVEL    LIMIT:BURST
loc        net         ACCEPT
net        all         DROP        info
all        all         REJECT      info</pre><p>In the two-interface
    sample, the line below is included but commented out. If you want your
    firewall system to have full access to servers on the Internet, uncomment
    that line. </p><pre class="programlisting">#SOURCE    DEST        POLICY      LOG LEVEL    LIMIT:BURST
$FW        net         ACCEPT</pre><p> The above policy will:
    </p><div class="itemizedlist"><ul type="disc"><li><p>Allow all connection requests from your local network to the
          Internet</p></li><li><p>Drop (ignore) all connection requests from the Internet to
          your firewall or local network</p></li><li><p>Optionally accept all connection requests from the firewall to
          the Internet (if you uncomment the additional policy)</p></li><li><p>reject all other connection requests.</p></li></ul></div><p> The word <em class="firstterm">info</em> in the LOG LEVEL
    column for the DROP and REJECT policies indicates that packets dropped or
    rejected under those policies should be <a class="ulink" href="shorewall_logging.html" target="_self">logged at that level</a>.</p><p><img src="images/BD21298_.gif" /></p><p>It is important to note that Shorewall policies (and rules) refer to
    <span class="bold"><strong>connections</strong></span> and not packet flow. With the
    policies defined in the <code class="filename">/etc/shorewall/policy</code> file shown above,
    connections are allowed from the <span class="emphasis"><em>loc</em></span> zone to the
    <span class="emphasis"><em>net</em></span> zone even though connections are not allowed from
    the <span class="emphasis"><em>loc</em></span> zone to the firewall itself.</p><p>At this point, edit your <code class="filename">/etc/shorewall/</code><code class="filename">policy</code>
    and make any changes that you wish.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Interfaces"></a>Network Interfaces</h2></div></div></div><div class="mediaobject" align="center"><img src="images/basics.png" align="middle" /></div><p>The firewall has two network interfaces. Where Internet connectivity
    is through a cable or <acronym class="acronym">DSL</acronym> “<span class="quote">Modem</span>”, the
    <span class="emphasis"><em>External Interface</em></span> will be the Ethernet adapter that
    is connected to that “<span class="quote">Modem</span>” (e.g., <code class="filename">eth0</code>) unless you connect via
    <span class="emphasis"><em>Point-to-Point Protocol</em></span> over Ethernet
    (<acronym class="acronym">PPPoE</acronym>) or <span class="emphasis"><em>Point-to-Point Tunneling
    Protocol</em></span> (<acronym class="acronym">PPTP</acronym>) in which case the External
    Interface will be a <code class="literal">ppp</code> interface (e.g., <code class="filename">ppp0</code>). If you connect via a regular modem,
    your External Interface will also be <code class="filename">ppp0</code>. If you connect via
    <acronym class="acronym">ISDN</acronym>, your external interface will be <code class="filename">ippp0</code>.</p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>Be sure you know which interface is your external interface. Many
      hours have been spent floundering by users who have configured the wrong
      interface. If you are unsure, then as root type <span class="command"><strong>ip route
      ls</strong></span> at the command line. The device listed in the last
      (default) route should be your external interface.</p><p>Example:</p><pre class="programlisting">root@lists:~# ip route ls
192.168.1.1 dev eth0  scope link 
192.168.2.2 dev tun0  proto kernel  scope link  src 192.168.2.1 
192.168.3.0/24 dev br0  proto kernel  scope link  src 192.168.3.254 
10.13.10.0/24 dev tun1  scope link 
192.168.2.0/24 via 192.168.2.2 dev tun0 
192.168.1.0/24 dev br0  proto kernel  scope link  src 192.168.1.254 
206.124.146.0/24 dev eth0  proto kernel  scope link  src 206.124.146.176 
10.10.10.0/24 dev tun1  scope link 
default via 206.124.146.254 dev <span class="bold"><strong>eth0</strong></span> 
root@lists:~# </pre><p>In that example, <code class="filename">eth0</code> is
      the external interface.</p></div><p><img src="images/BD21298_.gif" /></p><p>I<span class="bold"><strong>f your external interface is <code class="filename">ppp0</code> or <code class="filename">ippp0</code> then you will want to set
    <code class="varname">CLAMPMSS=yes</code> in <code class="filename">/etc/shorewall/</code><code class="filename">shorewall.conf</code></strong></span>.</p><p>Your <span class="emphasis"><em>Internal Interface</em></span> will be an Ethernet
    adapter (<code class="filename">eth1</code> or <code class="filename">eth0</code>) and will be connected to a hub or
    switch. Your other computers will be connected to the same hub/switch
    (note: If you have only a single internal system, you can connect the
    firewall directly to the computer using a cross-over cable). </p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><span class="bold"><strong>Do not connect the internal and external
        interface to the same hub or switch except for testing</strong></span>.You
        can test using this kind of configuration if you specify the <span class="bold"><strong>arp_filter</strong></span> option or the <span class="bold"><strong>arp_ignore</strong></span> option in <code class="filename">/etc/shorewall/</code><code class="filename">interfaces</code>
        for all interfaces connected to the common hub/switch. <span class="bold"><strong>Using such a setup with a production firewall is strongly
        recommended against</strong></span>.</p></div><p> <img src="images/BD21298_.gif" /></p><p>The Shorewall two-interface sample configuration assumes that the
    external interface is <code class="filename">eth0</code> and the
    internal interface is <code class="filename">eth1</code>. If
    your configuration is different, you will have to modify the sample
    <code class="filename">/etc/shorewall/</code><code class="filename">interfaces</code>
    file accordingly. While you are there, you may wish to review the list of
    options that are specified for the interfaces. Some hints:</p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>If your external interface is <code class="filename">ppp0</code> or <code class="filename">ippp0</code>, you can replace the
        <code class="varname">detect</code> in the second column with a “<span class="quote">-</span>”
        (minus the quotes).</p></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>If your external interface is <code class="filename">ppp0</code> or <code class="filename">ippp0</code> or if you have a static
        <acronym class="acronym">IP</acronym> address, you can remove <code class="varname">dhcp</code>
        from the option list.</p></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>If your internal interface is a bridge create using the
        <span class="command"><strong>brctl</strong></span> utility then <span class="bold"><strong>you must
        add the <code class="varname">routeback</code> option to the option
        list.</strong></span></p></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Addresses"></a>IP Addresses</h2></div></div></div><p>Before going further, we should say a few words about Internet
    Protocol (<acronym class="acronym">IP</acronym>) addresses. Normally, your
    <acronym class="acronym">ISP</acronym> will assign you a single Public IP address. This
    address may be assigned via the Dynamic Host Configuration Protocol
    (<acronym class="acronym">DHCP</acronym>) or as part of establishing your connection when
    you dial in (standard modem) or establish your <acronym class="acronym">PPP</acronym>
    connection. In rare cases, your <acronym class="acronym">ISP</acronym> may assign you a
    static <acronym class="acronym">IP</acronym> address; that means that you configure your
    firewall's external interface to use that address permanently. However
    your external address is assigned, it will be shared by all of your
    systems when you access the Internet. You will have to assign your own
    addresses in your internal network (the Internal Interface on your
    firewall plus your other computers). <span class="bold"><strong>RFC
    1918</strong></span> reserves several <span class="emphasis"><em>Private</em></span>
    <acronym class="acronym">IP</acronym> address ranges for this purpose: </p><pre class="programlisting">10.0.0.0    - 10.255.255.255
172.16.0.0  - 172.31.255.255
192.168.0.0 - 192.168.255.255</pre><p> <img src="images/BD21298_.gif" /></p><p>Before starting Shorewall, <span class="bold"><strong>you should look at
    the IP address of your external interface and if it is one of the above
    ranges, you should remove the 'norfc1918' option from the external
    interface's entry in <code class="filename">/etc/shorewall/</code><code class="filename">interfaces</code>.</strong></span></p><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Tip</h3><p>To determine the IP address of your external interface, as root
        type <span class="command"><strong>ip addr ls dev &lt;interface&gt;</strong></span> at the
        command line where &lt;<span class="emphasis"><em>interface</em></span>&gt; is your
        external interface. The line beginning with <span class="emphasis"><em>inet</em></span>
        identifies your IP address.</p><p>Example:</p><pre class="programlisting">root@lists:~# ip addr ls dev eth0
2: eth0: &lt;BROADCAST,MULTICAST,UP,10000&gt; mtu 1500 qdisc htb qlen 1000
    link/ether 00:02:e3:08:48:4c brd ff:ff:ff:ff:ff:ff
    inet <span class="bold"><strong>206.124.146.176</strong></span>/24 brd 206.124.146.255 scope global eth0
    inet6 fe80::202:e3ff:fe08:484c/64 scope link 
       valid_lft forever preferred_lft forever
root@lists:~# </pre><p>In this example, the IP address of the external interface is
        206.124.146.176</p></div><p>You will want to assign your addresses from the same sub-network
    (subnet). For our purposes, we can consider a subnet to consists of a
    range of addresses <code class="varname">x.y.z.0 - x.y.z.255</code>. Such a subnet
    will have a Subnet Mask of <code class="systemitem">255.255.255.0</code>. The address
    <code class="varname">x.y.z.0</code> is reserved as the <span class="emphasis"><em>Subnet
    Address</em></span> and <code class="varname">x.y.z.255</code> is reserved as the
    <span class="emphasis"><em>Subnet Broadcast Address</em></span>. In Shorewall, a subnet is
    described using <a class="ulink" href="shorewall_setup_guide.htm#Subnets" target="_self">Classless
    InterDomain Routing (CIDR) notation</a> with consists of the subnet
    address followed by <code class="varname">/24</code>. The “<span class="quote">24</span>” refers
    to the number of consecutive leading “<span class="quote">1</span>” bits from the left
    of the subnet mask. </p><div class="informaltable"><table border="1"><colgroup><col /><col /></colgroup><tbody valign="middle"><tr valign="middle"><td align="left" valign="middle"><span class="bold"><strong>Range:</strong></span></td><td align="left" valign="middle"><code class="systemitem">10.10.10.0</code> -
              <code class="systemitem">10.10.10.255</code></td></tr><tr><td align="left" valign="middle"><span class="bold"><strong>Subnet
              Address:</strong></span></td><td align="left" valign="middle"><code class="systemitem">10.10.10.0</code></td></tr><tr><td align="left" valign="middle"><span class="bold"><strong>Broadcast
              Address:</strong></span></td><td align="left" valign="middle"><code class="systemitem">10.10.10.255</code></td></tr><tr><td align="left" valign="middle"><span class="bold"><strong>CIDR
              Notation:</strong></span></td><td align="left" valign="middle"><code class="systemitem">10.10.10.0/24</code></td></tr></tbody></table></div><p> It is conventional to assign the internal interface
    either the first usable address in the subnet (<code class="systemitem">10.10.10.1</code> in the above example) or the
    last usable address (<code class="systemitem">10.10.10.254</code>).</p><p>One of the purposes of subnetting is to allow all computers in the
    subnet to understand which other computers can be communicated with
    directly. To communicate with systems outside of the subnetwork, systems
    send packets through a gateway (router).</p><p><img src="images/BD21298_.gif" /></p><p>Your local computers (computer 1 and computer 2 in the above
    diagram) should be configured with their default gateway to be the
    <acronym class="acronym">IP</acronym> address of the firewall's internal interface.</p><p>The foregoing short discussion barely scratches the surface
    regarding subnetting and routing. If you are interested in learning more
    about <acronym class="acronym">IP</acronym> addressing and routing, I highly recommend
    “<span class="quote">IP Fundamentals: What Everyone Needs to Know about Addressing &amp;
    Routing</span>”, Thomas A. Maufer, Prentice-Hall, 1999, ISBN 0-13-975483-0
    (<a class="ulink" href="http://www.phptr.com/browse/product.asp?product_id={58D4F6D4-54C5-48BA-8EDD-86EBD7A42AF6}" target="_self">link</a>).</p><p><a id="Diagram"></a>The remainder of this guide will assume that you have
    configured your network as shown here: </p><div class="mediaobject" align="center"><img src="images/basics1.png" align="middle" /></div><p> The default gateway for computer's 1 &amp; 2 would be
    <code class="systemitem">10.10.10.254</code>. </p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>Your <acronym class="acronym">ISP</acronym> might assign your external interface
        an <span class="bold"><strong>RFC 1918</strong></span> address. If that address
        is in the <code class="systemitem">10.10.10.0/24</code>
        subnet then <span class="bold"><strong>you will need to select a DIFFERENT
        RFC 1918 subnet for your local network.</strong></span></p></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="SNAT"></a>IP Masquerading (SNAT)</h2></div></div></div><p>The addresses reserved by RFC 1918 are sometimes referred to as
    <em class="firstterm">non-routable</em> because the Internet backbone routers
    don't forward packets which have an RFC-1918 destination address. When one
    of your local systems (let's assume computer 1 in the <a class="link" href="#Diagram">above diagram</a>) sends a connection request to an
    Internet host, the firewall must perform <span class="emphasis"><em>Network Address
    Translation</em></span> (<acronym class="acronym">NAT</acronym>). The firewall rewrites the
    source address in the packet to be the address of the firewall's external
    interface; in other words, the firewall makes it appear to the destination
    Internet host as if the firewall itself is initiating the connection. This
    is necessary so that the destination host will be able to route return
    packets back to the firewall (remember that packets whose destination
    address is reserved by RFC 1918 can't be routed across the Internet so the
    remote host can't address its response to computer 1). When the firewall
    receives a return packet, it rewrites the destination address back to
    <code class="systemitem">10.10.10.1</code> and forwards the
    packet on to computer 1.</p><p>On Linux systems, the above process is often referred to as
    <span class="emphasis"><em>IP Masquerading</em></span> but you will also see the term
    <span class="emphasis"><em>Source Network Address Translation</em></span>
    (<acronym class="acronym">SNAT</acronym>) used. Shorewall follows the convention used with
    Netfilter: </p><div class="itemizedlist"><ul type="disc"><li><p><span class="emphasis"><em>Masquerade</em></span> describes the case where you
          let your firewall system automatically detect the external interface
          address.</p></li><li><p><span class="emphasis"><em><acronym class="acronym">SNAT</acronym></em></span> refers to the
          case when you explicitly specify the source address that you want
          outbound packets from your local network to use.</p></li></ul></div><p> In Shorewall, both <span class="emphasis"><em>Masquerading</em></span> and
    <span class="emphasis"><em><acronym class="acronym">SNAT</acronym></em></span> are configured with entries
    in the <a class="ulink" href="manpages/shorewall-masq.html" target="_self"><code class="filename">/etc/shorewall/</code><code class="filename">masq</code></a>
    file. You will normally use Masquerading if your external
    <acronym class="acronym">IP</acronym> is dynamic and <acronym class="acronym">SNAT</acronym> if the
    <acronym class="acronym">IP</acronym> is static.</p><p><img src="images/BD21298_.gif" /></p><p>If your external firewall interface is <code class="filename">eth0</code>, you do not need to modify the file
    provided with <a class="link" href="#Concepts" title="Shorewall Concepts">the sample</a>. Otherwise, edit
    <code class="filename">/etc/shorewall/</code><code class="filename">masq</code> and
    change the first column to the name of your external interface and the
    second column to the name of your internal interface.</p><p><img src="images/BD21298_.gif" /></p><p>If your external <acronym class="acronym">IP</acronym> is static, you can enter it
    in the third column in the <code class="filename">/etc/shorewall/</code><code class="filename">masq</code>
    entry if you like although your firewall will work fine if you leave that
    column empty (Masquerade). Entering your static <acronym class="acronym">IP</acronym> in
    column 3 (SNAT) makes the processing of outgoing packets a little more
    efficient.</p><p><img src="images/BD21298_.gif" /></p><p>I<span class="bold"><strong>f you are using the Debian package, please
    check your <code class="filename">shorewall.conf</code> file to ensure that the
    following is set correctly; if it is not, change it
    appropriately:</strong></span> </p><div class="itemizedlist"><ul type="disc" compact="compact"><li><p><code class="varname">IP_FORWARDING=On</code></p></li></ul></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="DNAT"></a>Port Forwarding (DNAT)</h2></div></div></div><p>One of your goals may be to run one or more servers on your local
    computers. Because these computers have RFC-1918 addresses, it is not
    possible for clients on the Internet to connect directly to them. It is
    rather necessary for those clients to address their connection requests to
    the firewall who rewrites the destination address to the address of your
    server and forwards the packet to that server. When your server responds,
    the firewall automatically performs <acronym class="acronym"><a class="link" href="#SNAT" title="IP Masquerading (SNAT)">SNAT</a></acronym> to rewrite the source address in the
    response.</p><p>The above process is called <span class="emphasis"><em>Port Forwarding</em></span> or
    <span class="emphasis"><em>Destination Network Address Translation</em></span>
    (<acronym class="acronym">DNAT</acronym>). You configure port forwarding using
    <acronym class="acronym">DNAT</acronym> rules in the <code class="filename">/etc/shorewall/</code><code class="filename">rules</code>
    file.</p><p>The general form of a simple port forwarding rule in <code class="filename">/etc/shorewall/</code><code class="filename">rules</code> is:
    </p><pre class="programlisting">#ACTION   SOURCE    DEST                                          PROTO      DEST PORT(S)
DNAT      net       loc:<span class="emphasis"><em>&lt;server local ip address&gt;</em></span>[:<span class="emphasis"><em>&lt;server port&gt;</em></span>] <span class="emphasis"><em>&lt;protocol&gt;</em></span> <span class="emphasis"><em>&lt;port&gt;</em></span></pre><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>Be sure to add your rules after the line that reads <span class="bold"><strong>SECTION NEW.</strong></span></p></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>The server must have a static IP address. If you assign IP
        addresses to your local system using DHCP, you need to configure your
        DHCP server to always assign the same IP address to systems that are
        the target of a DNAT rule.</p></div><p>Shorewall has <a class="ulink" href="Macros.html" target="_self">macros</a> for
    many popular applications. Look at the output of <span class="command"><strong>shorewall show
    macros</strong></span> to see what is available in your release. Macros simplify
    creating DNAT rules by supplying the protocol and port(s) as shown in the
    following examples.</p><div class="example"><a id="Example1"></a><p class="title"><b>Example 1. Web Server</b></p><div class="example-contents"><p>You run a Web Server on computer 2 in <a class="link" href="#Diagram">the above diagram</a> and you want to forward
        incoming <acronym class="acronym">TCP</acronym> port 80 to that system:
        </p><pre class="programlisting">#ACTION   SOURCE    DEST             PROTO     DEST PORT(S)
Web/DNAT  net       loc:10.10.10.2</pre></div></div><p><br class="example-break" /> </p><div class="example"><a id="Example2"></a><p class="title"><b>Example 2. FTP Server</b></p><div class="example-contents"><p>You run an <acronym class="acronym">FTP</acronym> Server on <a class="link" href="#Diagram">computer 1</a> so you want to forward incoming
        <acronym class="acronym">TCP</acronym> port 21 to that system: </p><pre class="programlisting">#ACTION    SOURCE    DEST            PROTO     DEST PORT(S)
FTP/DNAT   net       loc:10.10.10.1</pre><p> For
        <acronym class="acronym">FTP</acronym>, you will also need to have
        <acronym class="acronym">FTP</acronym> connection tracking and <acronym class="acronym">NAT</acronym>
        support in your kernel. For vendor-supplied kernels, this means that
        the <code class="filename">ip_conntrack_ftp</code> and
        <code class="filename">ip_nat_ftp</code> modules
        (<code class="filename">nf_conntrack_ftp</code> and
        <code class="filename">nf_nat_ftp</code> in later 2.6 kernels) must be loaded.
        Shorewall will automatically load these modules if they are available
        and located in the standard place under <code class="filename">/lib/modules/&lt;kernel
        version&gt;/kernel/net/ipv4/netfilter</code>. See the <a class="ulink" href="FTP.html" target="_self">Shorewall FTP documentation</a> for more
        information.</p></div></div><p><br class="example-break" /> A couple of important points to keep in mind: </p><div class="itemizedlist"><ul type="disc"><li><p>You must test the above rule from a client outside of your
          local network (i.e., don't test from a browser running on computers
          1 or 2 or on the firewall). If you want to be able to access your
          web server and/or <acronym class="acronym">FTP</acronym> server from inside your
          firewall using the <acronym class="acronym">IP</acronym> address of your external
          interface, see <a class="ulink" href="FAQ.htm#faq2" target="_self">Shorewall FAQ
          #2</a>.</p></li><li><p>Many <acronym class="acronym">ISP</acronym>s block incoming connection
          requests to port 80. If you have problems connecting to your web
          server, try the following rule and try connecting to port
          5000.</p><pre class="programlisting">#ACTION    SOURCE    DEST               PROTO     DEST PORT(S)
DNAT       net       loc:10.10.10.2:80  tcp       5000</pre></li></ul></div><p> <img src="images/BD21298_.gif" /></p><p>At this point, modify <code class="filename">/etc/shorewall/</code><code class="filename">rules</code> to
    add any <acronym class="acronym">DNAT</acronym> rules that you require.</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>When testing DNAT rules like those shown above, you must test from
      a client OUTSIDE YOUR FIREWALL (in the 'net' zone). You cannot test
      these rules from inside the firewall!</p><p>For DNAT troubleshooting tips, <a class="ulink" href="FAQ.htm#faq1a" target="_self">see FAQs
      1a and 1b</a>.</p></div><p>For information about DNAT when there are multiple external IP
    addresses, see the <a class="ulink" href="Shorewall_and_Aliased_Interfaces.html" target="_self">Shorewall Aliased Interface
    documentation</a> and the <a class="ulink" href="shorewall_setup_guide.htm#dnat" target="_self">Shorewall Setup Guide</a>.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="DNS"></a>Domain Name Server (DNS)</h2></div></div></div><p>Normally, when you connect to your ISP, as part of getting an IP
    address your firewall's <span class="emphasis"><em>Domain Name Service</em></span>
    (<acronym class="acronym">DNS</acronym>) resolver will be automatically configured (e.g.,
    the <code class="filename">/etc/</code><code class="filename">resolv.conf</code> file
    will be written). Alternatively, your ISP may have given you the
    <acronym class="acronym">IP</acronym> address of a pair of <acronym class="acronym">DNS</acronym> name
    servers for you to manually configure as your primary and secondary name
    servers. Regardless of how <acronym class="acronym">DNS</acronym> gets configured on your
    firewall, it is your responsibility to configure the resolver in your
    internal systems. You can take one of two approaches: </p><div class="itemizedlist"><ul type="disc" compact="compact"><li><p>You can configure your internal systems to use your ISP's name
          servers. If your ISP gave you the addresses of their servers or if
          those addresses are available on their web site, you can configure
          your internal systems to use those addresses. If that information
          isn't available, look in /etc/resolv.conf on your firewall system --
          the name servers are given in "nameserver" records in that
          file.</p></li><li><p><a id="cachingdns"></a> You can configure a
          <span class="emphasis"><em>Caching Name Server</em></span> on your firewall.
          <span class="trademark">Red Hat</span>™ has an <acronym class="acronym">RPM</acronym> for a
          caching name server (the <acronym class="acronym">RPM</acronym> also requires the
          <span class="command"><strong>bind</strong></span><acronym class="acronym">RPM</acronym>) and for Bering users,
          there is <span class="command"><strong>dnscache.lrp</strong></span>. If you take this approach,
          you configure your internal systems to use the firewall itself as
          their primary (and only) name server. You use the internal
          <acronym class="acronym">IP</acronym> address of the firewall (<code class="systemitem">10.10.10.254</code> in the example above)
          for the name server address. To allow your local systems to talk to
          your caching name server, you must open port 53 (both
          <acronym class="acronym">UDP</acronym> and <acronym class="acronym">TCP</acronym>) from the local
          network to the firewall; you do that by adding the following rules
          in <code class="filename">/etc/shorewall/</code><code class="filename">rules</code>.
          </p><pre class="programlisting">#ACTION    SOURCE    DEST               PROTO     DEST PORT(S)
DNS/ACCEPT loc       $FW</pre></li></ul></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Open"></a>Other Connections</h2></div></div></div><p>The two-interface sample includes the following rules:
    </p><pre class="programlisting">#ACTION     SOURCE    DEST               PROTO     DEST PORT(S)
DNS/ACCEPT  $FW       net</pre><p>This rule allows
    <acronym class="acronym">DNS</acronym> access from your firewall and may be removed if you
    uncommented the line in <code class="filename">/etc/shorewall/</code><code class="filename">policy</code>
    allowing all connections from the firewall to the Internet.</p><p>In the rule shown above, “<span class="quote">DNS/ACCEPT</span>” is an example of
    a <span class="emphasis"><em>macro invocation</em></span>. Shorewall includes a number of
    macros (see <code class="filename">/usr/share/shorewall/macro.*</code>) and <a class="ulink" href="Macros.html" target="_self">you can add your own</a>.</p><p>You don't have to use defined macros when coding a rule in
    <code class="filename">/etc/shorewall/rules</code>; Shorewall will start slightly
    faster if you code your rules directly rather than using macros. The the
    rule shown above could also have been coded as follows:</p><pre class="programlisting">#ACTION    SOURCE    DEST               PROTO     DEST PORT(S)
ACCEPT     $FW       net                udp       53
ACCEPT     $FW       net                tcp       53</pre><p>In cases where Shorewall doesn't include a defined macro to meet
    your needs, you can either define the macro yourself or you can simply
    code the appropriate rules directly.</p><p>The sample also includes: </p><pre class="programlisting">#ACTION      SOURCE    DEST               PROTO     DEST PORT(S)
SSH/ACCEPT   loc       $FW  </pre><p>That rule allows you to run an
    <acronym class="acronym">SSH</acronym> server on your firewall and connect to that server
    from your local systems.</p><p>If you wish to enable other connections from your firewall to other
    systems, the general format using a macro is: </p><pre class="programlisting">#ACTION         SOURCE    DEST               PROTO      DEST PORT(S)
&lt;macro&gt;/ACCEPT  $FW       <span class="emphasis"><em>&lt;destination zone&gt;</em></span></pre><p>The
    general format when not using defined actions is:</p><pre class="programlisting">#ACTION    SOURCE    DEST               PROTO      DEST PORT(S)
ACCEPT     $FW       <span class="emphasis"><em>&lt;destination zone&gt; &lt;protocol&gt; &lt;port&gt;</em></span></pre><div class="example"><a id="Example3"></a><p class="title"><b>Example 3. Web Server on Firewall</b></p><div class="example-contents"><p>You want to run a Web Server on your firewall system:
        </p><pre class="programlisting">#ACTION     SOURCE    DEST               PROTO     DEST PORT(S)
Web/ACCEPT  net       $FW
Web/ACCEPT  loc       $FW       </pre><p>Those two rules would of
        course be in addition to the rules listed above under “<span class="quote"><a class="link" href="#cachingdns">You can configure a Caching Name Server on your
        firewall</a></span>”.</p></div></div><p><br class="example-break" /> If you don't know what port and protocol a particular
    application uses, look <a class="ulink" href="ports.htm" target="_self">here</a>. </p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>I don't recommend enabling <span class="command"><strong>telnet</strong></span> to/from the
        Internet because it uses clear text (even for login!). If you want
        shell access to your firewall from the Internet, use
        <acronym class="acronym">SSH</acronym>:</p><pre class="programlisting">#ACTION      SOURCE    DEST               PROTO     DEST PORT(S)
SSH/ACCEPT   net       $FW</pre></div><p> <img src="images/leaflogo.gif" />Bering users will want to add the following two rules to be
    compatible with Jacques's Shorewall configuration.</p><pre class="programlisting">#ACTION    SOURCE    DEST    PROTO     DEST PORT(S)
ACCEPT     loc       $FW     udp       53          #Allow DNS Cache to work
ACCEPT     loc       $FW     tcp       80          #Allow Weblet to work</pre><p>
    <img src="images/BD21298_.gif" /></p><p>Now edit your <code class="filename">/etc/shorewall/</code><code class="filename">rules</code>
    file to add or delete other connections as required.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Logging"></a>Logging</h2></div></div></div><p>Shorewall does not maintain a log itself but rather relies on your
    <a class="ulink" href="shorewall_logging.htm" target="_self">system's logging configuration</a>.
    The following <a class="ulink" href="manpages/shorewall.html" target="_self">commands</a> rely
    on knowing where Netfilter messages are logged:</p><div class="itemizedlist"><ul type="disc"><li><p><span class="command"><strong>shorewall show log</strong></span> (Displays the last 20
        netfilter log messages)</p></li><li><p><span class="command"><strong>shorewall logwatch</strong></span> (Polls the log at a
        settable interval</p></li><li><p><span class="command"><strong>shorewall dump</strong></span> (Produces an extensive report
        for inclusion in Shorewall problem reports)</p></li></ul></div><p>It is important that these commands work properly because when you
    encounter connection problems when Shorewall is running, the first thing
    that you should do is to look at the Netfilter log; with the help of
    <a class="ulink" href="FAQ.htm#faq17" target="_self">Shorewall FAQ 17</a>, you can usually
    resolve the problem quickly.</p><p>Most commonly, Netfilter messages are logged to
    <code class="filename">/var/log/messages</code>. Recent
    <span class="trademark">SuSE/OpenSuSE</span>™ releases come preconfigured with
    syslog-ng and log netfilter messages to
    <code class="filename">/var/log/firewall</code>.</p><p><img src="images/BD21298_.gif" /></p><p>If you are running a distribution that logs netfilter messages to a
    log other than <code class="filename">/var/log/messages</code>, then modify the
    LOGFILE setting in <code class="filename">/etc/shorewall/shorewall.conf</code> to
    specify the name of your log.</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>The LOGFILE setting does not control where the Netfilter log is
      maintained -- it simply tells the /sbin/<code class="filename">shorewall</code>
      utility where to find the log.</p></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Other"></a>Some Things to Keep in Mind</h2></div></div></div><div class="itemizedlist"><ul type="disc"><li><p><span class="bold"><strong>You cannot test your firewall from the
        inside</strong></span>. Just because you send requests to your firewall
        external IP address does not mean that the request will be associated
        with the external interface or the “<span class="quote">net</span>” zone. Any
        traffic that you generate from the local network will be associated
        with your local interface and will be treated as loc-&gt;fw
        traffic.</p></li><li><p><span class="bold"><strong>IP addresses are properties of systems,
        not of interfaces</strong></span>. It is a mistake to believe that your
        firewall is able to forward packets just because you can ping the IP
        address of all of the firewall's interfaces from the local network.
        The only conclusion you can draw from such pinging success is that the
        link between the local system and the firewall works and that you
        probably have the local system's default gateway set correctly.</p></li><li><p><span class="bold"><strong>All IP addresses configured on firewall
        interfaces are in the $FW (fw) zone</strong></span>. If 192.168.1.254 is
        the IP address of your internal interface then you can write
        “<span class="quote"><span class="bold"><strong>$FW:192.168.1.254</strong></span></span>” in a
        rule but you may not write “<span class="quote"><span class="bold"><strong>loc:192.168.1.254</strong></span></span>”. Similarly, it is
        nonsensical to add 192.168.1.254 to the <span class="bold"><strong>loc</strong></span> zone using an entry in
        <code class="filename">/etc/shorewall/hosts</code>.</p></li><li><p><span class="bold"><strong>Reply packets do NOT automatically follow
        the reverse path of the one taken by the original request</strong></span>.
        All packets are routed according to the routing table of the host at
        each step of the way. This issue commonly comes up when people install
        a Shorewall firewall parallel to an existing gateway and try to use
        DNAT through Shorewall without changing the default gateway of the
        system receiving the forwarded requests. Requests come in through the
        Shorewall firewall where the destination IP address gets rewritten but
        replies go out unmodified through the old gateway.</p></li><li><p><span class="bold"><strong>Shorewall itself has no notion of inside
        or outside</strong></span>. These concepts are embodied in how Shorewall is
        configured.</p></li></ul></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Starting"></a>Starting and Stopping Your Firewall</h2></div></div></div><p><img src="images/BD21298_.gif" /></p><p>The <a class="ulink" href="Install.htm" target="_self">installation procedure</a>
    configures your system to start Shorewall at system boot but startup is
    disabled so that your system won't try to start Shorewall before
    configuration is complete. Once you have completed configuration of your
    firewall, you must edit /etc/shorewall/shorewall.conf and set
    STARTUP_ENABLED=Yes.</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>Users of the .deb package must edit <code class="filename">/etc/default/</code><code class="filename">shorewall</code>
        and set <code class="varname">startup=1</code>.</p></div><p> The firewall is started using the “<span class="quote"><span class="command"><strong>shorewall
    start</strong></span></span>” command and stopped using
    “<span class="quote"><span class="command"><strong>shorewall stop</strong></span></span>”. When the firewall is
    stopped, routing is enabled on those hosts that have an entry in <code class="filename">/etc/shorewall/</code><code class="filename"><a class="ulink" href="manpages/shorewall-routestopped.html" target="_self">routestopped</a></code>.
    A running firewall may be restarted using the “<span class="quote"><span class="command"><strong>shorewall
    restart</strong></span></span>” command. If you want to totally remove any trace
    of Shorewall from your Netfilter configuration, use
    “<span class="quote"><span class="command"><strong>shorewall clear</strong></span></span>”.</p><p><img src="images/BD21298_.gif" /></p><p>The two-interface sample assumes that you want to enable routing
    to/from <code class="filename">eth1</code> (the local network)
    when Shorewall is stopped. If your local network isn't connected to
    <code class="filename">eth1</code> or if you wish to enable
    access to/from other hosts, change <code class="filename">/etc/shorewall/</code><code class="filename">routestopped</code>
    accordingly. </p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>If you are connected to your firewall from the Internet, do not
        issue a “<span class="quote"><span class="command"><strong>shorewall stop</strong></span></span>” command
        unless you have added an entry for the <acronym class="acronym">IP</acronym> address
        that you are connected from to <code class="filename">/etc/shorewall/</code><code class="filename">routestopped</code>.
        Also, I don't recommend using “<span class="quote"><span class="command"><strong>shorewall
        restart</strong></span></span>”; it is better to create an alternate
        configuration and test it using the “<span class="quote"><span class="command"><strong>shorewall
        try</strong></span></span>” command.</p></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Trouble"></a>If it Doesn't Work</h2></div></div></div><div class="itemizedlist"><ul type="disc"><li><p>Re-check each of the items flagged with a red arrow
        above.</p></li><li><p>Check your <a class="ulink" href="shorewall_logging.html" target="_self">log</a>.</p></li><li><p>Check the <a class="ulink" href="troubleshoot.htm" target="_self">Troubleshooting
        Guide</a>.</p></li><li><p>Check the <a class="ulink" href="FAQ.htm" target="_self">FAQ</a>.</p></li></ul></div></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Reading"></a>Additional Recommended Reading</h2></div></div></div><p>I highly recommend that you review the <a class="ulink" href="configuration_file_basics.htm" target="_self">Common Configuration File Features
    page</a> -- it contains helpful tips about Shorewall features than
    make administering your firewall easier.</p></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="Wireless"></a>Adding a Wireless Segment to your Two-Interface Firewall</h2></div></div></div><p>Once you have the two-interface setup working, the next logical step
    is to add a Wireless Network. The first step involves adding an additional
    network card to your firewall, either a Wireless card or an Ethernet card
    that is connected to a Wireless Access Point.</p><div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>When you add a network card, it won't necessarily be detected as
        the next highest Ethernet interface. For example, if you have two
        Ethernet cards in your system (<code class="filename">eth0</code> and <code class="filename">eth1</code>) and you add a third card that uses
        the same driver as one of the other two, that third card won't
        necessarily be detected as <code class="filename">eth2</code>; it could rather be detected as
        <code class="filename">eth0</code> or <code class="filename">eth1</code>! You can either live with that or
        you can shuffle the cards around in the slots until the new card is
        detected as <code class="filename">eth2</code>.</p><p><span class="bold"><strong>Update</strong></span>: Distributions are
        getting better about this. <span class="trademark">SuSE</span>™ now associates
        a unique interface name with each MAC address. Other distributions
        have add-on packages to manage the relationship between MAC addresses
        and device names.</p></div><p>Your new network will look similar to what is shown in the following
    figure.</p><div align="center"><img src="images/basics2.png" align="middle" /></div><p><img src="images/BD21298_.gif" /></p><p>The first thing to note is that the computers in your wireless
    network will be in a different subnet from those on your wired local LAN.
    In the above example, we have chosen to use the network 10.10.11.0/24.
    Computers 3 and 4 would be configured with a default gateway IP address of
    10.10.11.254.</p><p>Second, we have chosen to include the wireless network as part of
    the local zone. Since Shorewall allows intra-zone traffic by default,
    traffic may flow freely between the local wired network and the wireless
    network.</p><p><img src="images/BD21298_.gif" /></p><p>There are only two changes that need to be made to the Shorewall
    configuration:</p><div class="itemizedlist"><ul type="disc"><li><p>An entry needs to be added to
        <code class="filename">/etc/shorewall/interfaces</code> for the wireless
        network interface. If the wireless interface is <code class="filename">wlan0</code>, the entry might look like:</p><pre class="programlisting">#ZONE     INTERFACE       BROADCAST          OPTIONS
loc       wlan0           detect             maclist</pre><p>As shown in the above entry, I recommend using the <a class="ulink" href="MAC_Validation.html" target="_self">maclist option</a> for the wireless
        segment. By adding entries for computers 3 and 4 in
        <code class="filename">/etc/shorewall/maclist</code>, you help ensure that your
        neighbors aren't getting a free ride on your Internet connection.
        Start by omitting that option; when you have everything working, then
        add the option and configure your
        <code class="filename">/etc/shorewall/maclist</code> file.</p></li><li><p>You need to add an entry to the
        <code class="filename">/etc/shorewall/masq</code> file to masquerade traffic
        from the wireless network to the Internet. If your Internet interface
        is <code class="filename">eth0</code> and your wireless
        interface is <code class="filename">wlan0</code>, the entry
        would be:</p><pre class="programlisting">#INTERFACE           SUBNET             ADDRESS
eth0                 wlan0</pre></li></ul></div><p>One other thing to note. To get <span class="trademark">Microsoft</span>™
    networking working between the wireless and wired networks, you will need
    either a WINS server or a PDC. I personally use Samba configured as a WINS
    server running on my firewall. Running a WINS server on your firewall
    requires the rules listed in the <a class="ulink" href="samba.htm" target="_self">Shorewall/Samba
    documentation</a>.</p></div></div></body></html>