Sophie

Sophie

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

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>shorewall-rules</title><link rel="stylesheet" href="html.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /></head><body><div class="refentry" lang="en" xml:lang="en"><a id="id257168"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>rules — Shorewall rules file</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">/etc/shorewall/rules</code> </p></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="id257199"></a><h2>Description</h2><p>Entries in this file govern connection establishment by defining
    exceptions to the policies layed out in <a class="ulink" href="shorewall-policy.html" target="_self">shorewall-policy</a>(5). By default,
    subsequent requests and responses are automatically allowed using
    connection tracking. For any particular (source,dest) pair of zones, the
    rules are evaluated in the order in which they appear in this file and the
    first terminating match is the one that determines the disposition of the
    request. All rules are terminating except LOG and QUEUE rules.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>If you masquerade or use SNAT from a local system to the internet,
      you cannot use an ACCEPT rule to allow traffic from the internet to that
      system. You <span class="bold"><strong>must</strong></span> use a DNAT rule
      instead.</p></div><p>The rules file is divided into sections. Each section is introduced
    by a "Section Header" which is a line beginning with SECTION and followed
    by the section name.</p><p>Sections are as follows and must appear in the order listed:</p><div class="variablelist"><dl><dt><span class="term"><span class="bold"><strong>ESTABLISHED</strong></span></span></dt><dd><p>Packets in the ESTABLISHED state are processed by rules in
          this section.</p><p>The only ACTIONs allowed in this section are ACCEPT, DROP,
          REJECT, LOG and QUEUE</p><p>There is an implicit ACCEPT rule inserted at the end of this
          section.</p></dd><dt><span class="term"><span class="bold"><strong>RELATED</strong></span></span></dt><dd><p>Packets in the RELATED state are processed by rules in this
          section.</p><p>The only ACTIONs allowed in this section are ACCEPT, DROP,
          REJECT, LOG and QUEUE</p><p>There is an implicit ACCEPT rule inserted at the end of this
          section.</p></dd><dt><span class="term"><span class="bold"><strong>NEW</strong></span></span></dt><dd><p>Packets in the NEW and INVALID states are processed by rules
          in this section.</p></dd></dl></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>If you are not familiar with Netfilter to the point where you are
      comfortable with the differences between the various connection tracking
      states, then it is suggested that you omit the <span class="bold"><strong>ESTABLISHED</strong></span> and <span class="bold"><strong>RELATED</strong></span> sections and place all of your rules in
      the NEW section (That's after the line that reads SECTION NEW').</p></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>If you specify FASTACCEPT=Yes in <a class="ulink" href="shorewall.conf.html" target="_self">shorewall.conf</a>(5) then the <span class="bold"><strong>ESTABLISHED</strong></span> and <span class="bold"><strong>RELATED</strong></span> sections must be empty.</p></div><p>You may omit any section that you don't need. If no Section Headers
    appear in the file then all rules are assumed to be in the NEW
    section.</p><p>When defining rules that rewrite the destination IP address and/or
    port number (namely DNAT and REDIRECT rules), it is important to keep
    straight which columns in the file specify the packet before rewriting and
    which specify how the packet will look after rewriting.</p><div class="itemizedlist"><ul type="disc"><li><p>The DEST column specifies the final destination for the packet
        after rewriting and can include the final IP address and/or port
        number.</p></li><li><p>The remaining columns specify characteristics of the packet
        before rewriting. In particular, the ORIGINAL DEST column gives the
        original destination IP address of the packet and the DEST PORT(S)
        column give the original destination port(s).</p></li></ul></div><p>The columns in the file are as follows.</p><div class="variablelist"><dl><dt><span class="term"><span class="bold"><strong>ACTION</strong></span> - {<span class="bold"><strong>ACCEPT</strong></span>[<span class="bold"><strong><code class="option">+</code>|<code class="option">!</code></strong></span>]|<span class="bold"><strong>NONAT</strong></span>|<span class="bold"><strong>DROP[<code class="option">!</code>]</strong></span>|<span class="bold"><strong>REJECT</strong></span>[<code class="option">!</code>]|<span class="bold"><strong>DNAT</strong></span>[<span class="bold"><strong>-</strong></span>]|<span class="bold"><strong>SAME</strong></span>[<span class="bold"><strong>-</strong></span>]|<span class="bold"><strong>REDIRECT</strong></span>[<span class="bold"><strong>-</strong></span>]|<span class="bold"><strong>CONTINUE</strong></span>[<code class="option">!</code>]|<span class="bold"><strong>LOG</strong></span>|<span class="bold"><strong>QUEUE</strong></span>[<code class="option">!</code>]|<span class="bold"><strong>NFQUEUE</strong></span>[/<span class="emphasis"><em>queuenumber</em></span>]<span class="bold"><strong>|COMMENT</strong></span>|<span class="emphasis"><em>action</em></span>|<span class="emphasis"><em>macro</em></span>[<span class="bold"><strong>/</strong></span><span class="emphasis"><em>target</em></span>]}<span class="bold"><strong>[:</strong></span>{<span class="emphasis"><em>log-level</em></span>|<span class="bold"><strong>none</strong></span>}[<span class="bold"><strong><span class="bold"><strong>!</strong></span></strong></span>][<span class="bold"><strong>:</strong></span><span class="emphasis"><em>tag</em></span>]]</span></dt><dd><p>Specifies the action to be taken if the connection request
          matches the rule. Must be one of the following.</p><div class="variablelist"><dl><dt><span class="term"><span class="bold"><strong>ACCEPT</strong></span></span></dt><dd><p>Allow the connection request.</p></dd><dt><span class="term"><span class="bold"><strong>ACCEPT+</strong></span></span></dt><dd><p>like ACCEPT but also excludes the connection from any
                subsequent matching <span class="bold"><strong>DNAT</strong></span>[<span class="bold"><strong>-</strong></span>] or <span class="bold"><strong>REDIRECT</strong></span>[<span class="bold"><strong>-</strong></span>] rules</p></dd><dt><span class="term">ACCEPT!</span></dt><dd><p>like ACCEPT but exempts the rule from being suppressed
                by OPTIMIZE=1 in <a class="ulink" href="shorewall.conf.html" target="_self">shorewall.conf</a>(5).</p></dd><dt><span class="term"><span class="bold"><strong>NONAT</strong></span></span></dt><dd><p>Excludes the connection from any subsequent <span class="bold"><strong>DNAT</strong></span>[-] or <span class="bold"><strong>REDIRECT</strong></span>[-] rules but doesn't generate
                a rule to accept the traffic.</p></dd><dt><span class="term"><span class="bold"><strong>DROP</strong></span></span></dt><dd><p>Ignore the request.</p></dd><dt><span class="term">DROP!</span></dt><dd><p>like DROP but exempts the rule from being suppressed by
                OPTIMIZE=1 in <a class="ulink" href="shorewall.conf.html" target="_self">shorewall.conf</a>(5).</p></dd><dt><span class="term"><span class="bold"><strong>REJECT</strong></span></span></dt><dd><p>disallow the request and return an icmp-unreachable or
                an RST packet.</p></dd><dt><span class="term">REJECT!</span></dt><dd><p>like REJECT but exempts the rule from being suppressed
                by OPTIMIZE=1 in <a class="ulink" href="shorewall.conf.html" target="_self">shorewall.conf</a>(5).</p></dd><dt><span class="term"><span class="bold"><strong>DNAT</strong></span></span></dt><dd><p>Forward the request to another system (and optionally
                another port).</p></dd><dt><span class="term"><span class="bold"><strong>DNAT-</strong></span></span></dt><dd><p>Advanced users only.</p><p>Like <span class="bold"><strong>DNAT</strong></span> but only
                generates the <span class="bold"><strong>DNAT</strong></span> iptables
                rule and not the companion <span class="bold"><strong>ACCEPT</strong></span> rule.</p></dd><dt><span class="term"><span class="bold"><strong>SAME</strong></span></span></dt><dd><p>Similar to <span class="bold"><strong>DNAT</strong></span> except
                that the port may not be remapped and when multiple server
                addresses are listed, all requests from a given remote system
                go to the same server.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>Support for SAME is scheduled for removal from the
                    Linux kernel in 2008.</p></div></dd><dt><span class="term"><span class="bold"><strong>SAME-</strong></span></span></dt><dd><p>Advanced users only.</p><p>Like SAME but only generates the nat iptables rule and
                not the companion <span class="bold"><strong>ACCEPT</strong></span>
                rule.</p></dd><dt><span class="term"><span class="bold"><strong>REDIRECT</strong></span></span></dt><dd><p>Redirect the request to a server running on the
                firewall.</p></dd><dt><span class="term"><span class="bold"><strong>REDIRECT-</strong></span></span></dt><dd><p>Advanced users only.</p><p>Like <span class="bold"><strong>REDIRECT</strong></span> but only
                generates the <span class="bold"><strong>REDIRECT</strong></span>
                iptables rule and not the companion <span class="bold"><strong>ACCEPT</strong></span> rule.</p></dd><dt><span class="term"><span class="bold"><strong>CONTINUE</strong></span></span></dt><dd><p>For experts only.</p><p>Do not process any of the following rules for this
                (source zone,destination zone). If the source and/or
                destination IP address falls into a zone defined later in
                <a class="ulink" href="shorewall-zones.html" target="_self">shorewall-zones</a>(5)
                or in a parent zone of the source or destination zones, then
                this connection request will be passed to the rules defined
                for that (those) zone(s). See <a class="ulink" href="shorewall-nesting.html" target="_self">shorewall-nesting</a>(5) for
                additional information.</p></dd><dt><span class="term">CONTINUE!</span></dt><dd><p>like CONTINUE but exempts the rule from being suppressed
                by OPTIMIZE=1 in <a class="ulink" href="shorewall.conf.html" target="_self">shorewall.conf</a>(5).</p></dd><dt><span class="term"><span class="bold"><strong>LOG</strong></span></span></dt><dd><p>Simply log the packet and continue with the next
                rule.</p></dd><dt><span class="term"><span class="bold"><strong>QUEUE</strong></span></span></dt><dd><p>Queue the packet to a user-space application such as
                ftwall (http://p2pwall.sf.net). The application may reinsert
                the packet for further processing.</p></dd><dt><span class="term">QUEUE!</span></dt><dd><p>like QUEUE but exempts the rule from being suppressed by
                OPTIMIZE=1 in <a class="ulink" href="shorewall.conf.html" target="_self">shorewall.conf</a>(5).</p></dd><dt><span class="term">NFQUEUE</span></dt><dd><p>Only supported by Shorewall-perl &gt;= 4.0.3.</p><p>Queues the packet to a user-space application using the
                nfnetlink_queue mechanism. If a
                <em class="replaceable"><code>queuenumber</code></em> is not specified, queue
                zero (0) is assumed.</p></dd><dt><span class="term">NFQUEUE!</span></dt><dd><p>like NFQUEUE but exempts the rule from being suppressed
                by OPTIMIZE=1 in <a class="ulink" href="shorewall.conf.html" target="_self">shorewall.conf</a>(5).</p></dd><dt><span class="term"><span class="bold"><strong>COMMENT</strong></span></span></dt><dd><p>the rest of the line will be attached as a comment to
                the Netfilter rule(s) generated by the following entries. The
                comment will appear delimited by "/* ... */" in the output of
                "shorewall show &lt;chain&gt;". To stop the comment from being
                attached to further rules, simply include COMMENT on a line by
                itself.</p></dd><dt><span class="term"><span class="emphasis"><em>action</em></span></span></dt><dd><p>The name of an <span class="emphasis"><em>action</em></span> declared in
                <a class="ulink" href="shorewall-actions.html" target="_self">shorewall-actions</a>(5) or
                in /usr/share/shorewall/actions.std.</p></dd><dt><span class="term"><span class="emphasis"><em>macro</em></span></span></dt><dd><p>The name of a macro defined in a file named
                macro.<span class="emphasis"><em>macro</em></span>. If the macro accepts an
                action parameter (Look at the macro source to see if it has
                PARAM in the TARGET column) then the
                <span class="emphasis"><em>macro</em></span> name is followed by "/" and the
                <span class="emphasis"><em>target</em></span> (<span class="bold"><strong>ACCEPT</strong></span>, <span class="bold"><strong>DROP</strong></span>, <span class="bold"><strong>REJECT</strong></span>, ...) to be substituted for the
                parameter.</p><p>Example: FTP/ACCEPT.</p><pre class="programlisting"></pre></dd></dl></div><div class="blockquote"><blockquote class="blockquote"><p>The <span class="bold"><strong>ACTION</strong></span> may optionally
            be followed by ":" and a syslog log level (e.g, REJECT:info or
            DNAT:debug). This causes the packet to be logged at the specified
            level. Note that if the <span class="bold"><strong>ACTION</strong></span>
            involves destination network address translation (DNAT, REDIRECT,
            SAME, etc.) then the packet is logged <span class="bold"><strong>before</strong></span> the destination address is
            rewritten.</p><p>If the <span class="bold"><strong>ACTION</strong></span> names an
            <span class="emphasis"><em>action</em></span> declared in <a class="ulink" href="shorewall-actions.html" target="_self">shorewall-actions</a>(5) or in
            /usr/share/shorewall/actions.std then:</p><div class="itemizedlist"><ul type="disc"><li><p>If the log level is followed by "!' then all rules in
                the action are logged at the log level.</p></li><li><p>If the log level is not followed by "!" then only those
                rules in the action that do not specify logging are logged at
                the specified level.</p></li><li><p>The special log level <span class="bold"><strong>none!</strong></span> suppresses logging by the
                action.</p></li></ul></div><p>You may also specify <span class="bold"><strong>ULOG</strong></span>
            (must be in upper case) as a log level.This will log to the ULOG
            target for routing to a separate log through use of ulogd (<a class="ulink" href="http://www.netfilter.org/projects/ulogd/index.html" target="_self">http://www.netfilter.org/projects/ulogd/index.html</a>).</p><p>Actions specifying logging may be followed by a log tag (a
            string of alphanumeric characters) which is appended to the string
            generated by the LOGPREFIX (in <a class="ulink" href="shorewall.conf.html" target="_self">shorewall.conf</a>(5)).</p><p>Example: ACCEPT:info:ftp would include 'ftp ' at the end of
            the log prefix generated by the LOGPREFIX setting.</p></blockquote></div></dd><dt><span class="term"><span class="bold"><strong>SOURCE</strong></span> -
        {<span class="emphasis"><em>zone</em></span>|<span class="bold"><strong>all</strong></span>[<span class="bold"><strong>+</strong></span>][<span class="bold"><strong>-</strong></span>]}<span class="bold"><strong>[:</strong></span><span class="emphasis"><em>interface</em></span>][<span class="bold"><strong>:</strong></span>{<span class="emphasis"><em>address-or-range</em></span>[,<span class="emphasis"><em>address-or-range</em></span>]...[<span class="emphasis"><em>exclusion</em></span>]|<span class="emphasis"><em>exclusion</em></span>|<span class="bold"><strong>+</strong></span><span class="emphasis"><em>ipset</em></span>}</span></dt><dd><p>Source hosts to which the rule applies. May be a zone declared
          in /etc/shorewall/zones, <span class="bold"><strong>$FW</strong></span> to
          indicate the firewall itself, <span class="bold"><strong>all</strong></span>,
          <span class="bold"><strong>all+</strong></span>, <span class="bold"><strong>all-</strong></span>, <span class="bold"><strong>all+-</strong></span>
          or <span class="bold"><strong>none</strong></span>.</p><p>When <span class="bold"><strong>none</strong></span> is used either in
          the <span class="bold"><strong>SOURCE</strong></span> or <span class="bold"><strong>DEST</strong></span> column, the rule is ignored.</p><p><span class="bold"><strong>all</strong></span> means "All Zones",
          including the firewall itself. <span class="bold"><strong>all-</strong></span>
          means "All Zones, except the firewall itself". When <span class="bold"><strong>all</strong></span>[<span class="bold"><strong>-</strong></span>] is
          used either in the <span class="bold"><strong>SOURCE</strong></span> or
          <span class="bold"><strong>DEST</strong></span> column intra-zone traffic is
          not affected. When <span class="bold"><strong>all+</strong></span>[<span class="bold"><strong>-</strong></span>] is "used, intra-zone traffic is
          affected.</p><p>Except when <span class="bold"><strong>all</strong></span>[<span class="bold"><strong>+</strong></span>][<span class="bold"><strong>-</strong></span>] is
          specified, clients may be further restricted to a list of networks
          and/or hosts by appending ":" and a comma-separated list of network
          and/or host addresses. Hosts may be specified by IP or MAC address;
          mac addresses must begin with "~" and must use "-" as a
          separator.</p><p>Hosts may also be specified as an IP address range using the
          syntax
          <span class="emphasis"><em>lowaddress</em></span>-<span class="emphasis"><em>highaddress</em></span>.
          This requires that your kernel and iptables contain iprange match
          support. If your kernel and iptables have ipset match support then
          you may give the name of an ipset prefaced by "+". The ipset name
          may be optionally followed by a number from 1 to 6 enclosed in
          square brackets ([]) to indicate the number of levels of source
          bindings to be matched.</p><p>You may exclude certain hosts from the set already defined
          through use of an <span class="emphasis"><em>exclusion</em></span> (see <a class="ulink" href="shorewall-exclusion.html" target="_self">shorewall-exclusion</a>(5)).</p><p>Examples:</p><div class="variablelist"><dl><dt><span class="term">dmz:192.168.2.2</span></dt><dd><p>Host 192.168.2.2 in the DMZ</p></dd><dt><span class="term">net:155.186.235.0/24</span></dt><dd><p>Subnet 155.186.235.0/24 on the Internet</p></dd><dt><span class="term">loc:192.168.1.1,192.168.1.2</span></dt><dd><p>Hosts 192.168.1.1 and 192.168.1.2 in the local
                zone.</p></dd><dt><span class="term">loc:~00-A0-C9-15-39-78</span></dt><dd><p>Host in the local zone with MAC address
                00:A0:C9:15:39:78.</p></dd><dt><span class="term">net:192.0.2.11-192.0.2.17</span></dt><dd><p>Hosts 192.0.2.11-192.0.2.17 in the net zone.</p></dd><dt><span class="term">net:!192.0.2.11-192.0.2.17</span></dt><dd><p>All hosts in the net zone except for
                192.0.2.11-192.0.2.17.</p></dd><dt><span class="term">net:155.186.235.0/24!155.186.235.16/28</span></dt><dd><p>Subnet 155.186.235.0/24 on the Internet except for
                155.186.235.16/28</p></dd></dl></div><div class="blockquote"><blockquote class="blockquote"><p>Alternatively, clients may be specified by interface by
            appending ":" to the zone name followed by the interface name. For
            example, <span class="bold"><strong>loc:eth1</strong></span> specifies a
            client that communicates with the firewall system through eth1.
            This may be optionally followed by another colon (":") and an
            IP/MAC/subnet address as described above (e.g., <span class="bold"><strong>loc:eth1:192.168.1.5</strong></span>).</p><p>It is important to note that when <span class="bold"><strong>using
            Shorewall-shell</strong></span> and specifying an address list that will
            be split (i.e., a comma separated list), there is a subtle behavior
            which has the potential to cause confusion.  Consider the two
            examples below:</p></blockquote></div><p>Examples:</p><div class="variablelist"><dl><dt><span class="term">loc:eth1:192.168.1.3,192.168.1.5</span></dt><dd><p>Hosts 192.168.1.3 and 192.168.1.5 in the Local zone,
                with 192.168.1.3 coming from eth1 and 192.168.1.5 originating
                from any interface in the zone.</p></dd><dt><span class="term">loc:eth1:192.168.1.3,eth1:192.168.1.5</span></dt><dd><p>Hosts 192.168.1.3 and 192.168.1.5 in the Local zone,
                with <span class="bold"><strong>both</strong></span> originating from
                eth1.</p></dd></dl></div><div class="blockquote"><blockquote class="blockquote"><p>That is, the interface name must be explicitly stated for
            each member of the comma separated list.  Again, this distinction
            in behavior only occurs when <span class="bold"><strong>using
            Shorewall-shell</strong></span>.</p></blockquote></div></dd><dt><span class="term"><span class="bold"><strong>DEST</strong></span> -
        {<span class="emphasis"><em>zone</em></span>|<span class="bold"><strong>all</strong></span>[<span class="bold"><strong>+</strong></span>][<span class="bold"><strong>-</strong></span>]}<span class="bold"><strong>[:{</strong></span><span class="emphasis"><em>interface</em></span>|<span class="emphasis"><em>address-or-range</em></span>[,<span class="emphasis"><em>address-or-range</em></span>]...[<span class="emphasis"><em>exclusion</em></span>]|<span class="emphasis"><em>exclusion</em></span>|<span class="bold"><strong>+</strong></span><span class="emphasis"><em>ipset</em></span>}][<code class="option">:</code><em class="replaceable"><code>port</code></em>[:<span class="bold"><strong>random</strong></span>]]</span></dt><dd><p>Location of Server. May be a zone declared in <a class="ulink" href="shorewall-zones.html" target="_self">shorewall-zones</a>(5), $<span class="bold"><strong>FW</strong></span> to indicate the firewall itself, <span class="bold"><strong>all</strong></span>. <span class="bold"><strong>all+</strong></span> or
          <span class="bold"><strong>none</strong></span>.</p><p>When <span class="bold"><strong>none</strong></span> is used either in
          the <span class="bold"><strong>SOURCE</strong></span> or <span class="bold"><strong>DEST</strong></span> column, the rule is ignored.</p><p>When <span class="bold"><strong>all</strong></span> is used either in
          the <span class="bold"><strong>SOURCE</strong></span> or <span class="bold"><strong>DEST</strong></span> column intra-zone traffic is not
          affected. When <span class="bold"><strong>all+</strong></span> is used,
          intra-zone traffic is affected.</p><p>If the DEST <em class="replaceable"><code>zone</code></em> is a bport zone,
          then either:</p><div class="orderedlist"><ol type="a"><li><p>the SOURCE must be <code class="option">all[+][-]</code>, or</p></li><li><p>the SOURCE <em class="replaceable"><code>zone</code></em> must be
                another bport zone associated with the same bridge, or</p></li><li><p>the SOURCE <em class="replaceable"><code>zone</code></em> must be an
                ipv4 zone that is associated with only the same bridge.</p></li></ol></div><div class="blockquote"><blockquote class="blockquote"><p></p><p>Except when <span class="bold"><strong>all</strong></span>[<span class="bold"><strong>+]|[-</strong></span>] is specified, the server may be
            further restricted to a particular network, host or interface by
            appending ":" and the network, host or interface. See <span class="bold"><strong>SOURCE</strong></span> above.</p><p>You may exclude certain hosts from the set already defined
            through use of an <span class="emphasis"><em>exclusion</em></span> (see <a class="ulink" href="shorewall-exclusion.html" target="_self">shorewall-exclusion</a>(5)).</p><p>Restrictions:</p><p>1. MAC addresses are not allowed (this is a Netfilter
            restriction).</p><p>2. In <span class="bold"><strong>DNAT</strong></span> rules, only IP
            addresses are allowed; no FQDNs or subnet addresses are
            permitted.</p><p>3. You may not specify both an interface and an
            address.</p><p>Like in the <span class="bold"><strong>SOURCE</strong></span> column,
            you may specify a range of IP addresses using the syntax
            <span class="emphasis"><em>lowaddress</em></span>-<span class="emphasis"><em>highaddress</em></span>.
            When the <span class="bold"><strong>ACTION</strong></span> is <span class="bold"><strong>DNAT</strong></span> or <span class="bold"><strong>DNAT-</strong></span>, the connections will be assigned to
            addresses in the range in a round-robin fashion.</p><p>If you kernel and iptables have ipset match support then you
            may give the name of an ipset prefaced by "+". The ipset name may
            be optionally followed by a number from 1 to 6 enclosed in square
            brackets ([]) to indicate the number of levels of destination
            bindings to be matched. Only one of the <span class="bold"><strong>SOURCE</strong></span> and <span class="bold"><strong>DEST</strong></span> columns may specify an ipset
            name.</p><p>The <em class="replaceable"><code>port</code></em> that the server is
            listening on may be included and separated from the server's IP
            address by ":". If omitted, the firewall will not modifiy the
            destination port. A destination port may only be included if the
            <span class="bold"><strong>ACTION</strong></span> is <span class="bold"><strong>DNAT</strong></span> or <span class="bold"><strong>REDIRECT</strong></span>.</p><div class="variablelist"><dl><dt><span class="term">Example:</span></dt><dd><p><span class="bold"><strong>loc:192.168.1.3:3128</strong></span>
                  specifies a local server at IP address 192.168.1.3 and
                  listening on port 3128.</p></dd></dl></div><p>If you are using Shorewall-shell or Shorewall-perl before
            version 4.0.5, then the port number MUST be specified as an
            integer and not as a name from services(5). Shorewall-perl 4.0.5
            and later permit the <span class="emphasis"><em>port</em></span> to be specified as
            a service name. Additionally, Shorewall-perl 4.0.5 and later
            permit specifying a port range in the form
            <span class="emphasis"><em>lowport-highport</em></span> to cause connections to be
            assigned to ports in the range in round-robin fashion. When a port
            range is specified, <span class="emphasis"><em>lowport</em></span> and
            <span class="emphasis"><em>highport</em></span> must be given as integers; service
            names are not permitted. Beginning with Shorewall 4.0.6, the port
            range may be optionally followed by <span class="bold"><strong>:random</strong></span> which causes assignment to ports in
            the list to be random.</p><p>If the <span class="bold"><strong>ACTION</strong></span> is <span class="bold"><strong>REDIRECT</strong></span> or <span class="bold"><strong>REDIRECT-</strong></span>, this column needs only to
            contain the port number on the firewall that the request should be
            redirected to. That is equivalent to specifying
            <code class="option">$FW</code>::<em class="replaceable"><code>port</code></em>.</p></blockquote></div></dd><dt><span class="term"><span class="bold"><strong>PROTO</strong></span> (Optional) - {<span class="bold"><strong>-</strong></span>|<span class="bold"><strong>tcp:syn</strong></span>|<span class="bold"><strong>ipp2p</strong></span>|<span class="bold"><strong>ipp2p:udp</strong></span>|<span class="bold"><strong>ipp2p:all</strong></span>|<span class="emphasis"><em>protocol-number</em></span>|<span class="emphasis"><em>protocol-name</em></span>|<span class="bold"><strong>all}</strong></span></span></dt><dd><p>Protocol - <span class="bold"><strong>ipp2p</strong></span>* requires
          ipp2p match support in your kernel and iptables. <span class="bold"><strong>tcp:syn</strong></span> implies <span class="bold"><strong>tcp</strong></span> plus the SYN flag must be set and the
          RST,ACK and FIN flags must be reset.</p></dd><dt><span class="term"><span class="bold"><strong>DEST PORT(S) </strong></span>(Optional) -
        {<span class="bold"><strong>-</strong></span>|<span class="emphasis"><em>port-name-number-or-range</em></span>[<span class="bold"><strong>,</strong></span><span class="emphasis"><em>port-name-number-or-range</em></span>]...}</span></dt><dd><p>Destination Ports. A comma-separated list of Port names (from
          services(5)), port numbers or port ranges; if the protocol is
          <span class="bold"><strong>icmp</strong></span>, this column is interpreted as
          the destination icmp-type(s).</p><p>If the protocol is <span class="bold"><strong>ipp2p</strong></span>,
          this column is interpreted as an ipp2p option without the leading
          "--" (example <span class="bold"><strong>bit</strong></span> for bit-torrent).
          If no port is given, <span class="bold"><strong>ipp2p</strong></span> is
          assumed.</p><p>A port range is expressed as
          <span class="emphasis"><em>lowport</em></span>:<span class="emphasis"><em>highport</em></span>.</p><p>This column is ignored if <span class="bold"><strong>PROTO</strong></span> = <span class="bold"><strong>all</strong></span>
          but must be entered if any of the following columns are supplied. In
          that case, it is suggested that this field contain a dash (<span class="bold"><strong>-</strong></span>).</p><p>If your kernel contains multi-port match support, then only a
          single Netfilter rule will be generated if in this list and the
          <span class="bold"><strong>CLIENT PORT(S)</strong></span> list below:</p><p>1. There are 15 or less ports listed.</p><p>2. No port ranges are included or your kernel and iptables
          contain extended multiport match support.</p><p>Otherwise, unless you are using <a class="ulink" href="../Shorewall-perl.html" target="_self">Shorewall-perl</a>, a separate rule
          will be generated for each port. Shorewall-perl does not
          automatically break up lists into individual rules.</p></dd><dt><span class="term"><span class="bold"><strong>SOURCE PORT(S)</strong></span> (Optional) -
        {<span class="bold"><strong>-</strong></span>|<span class="emphasis"><em>port-name-number-or-range</em></span>[<span class="bold"><strong>,</strong></span><span class="emphasis"><em>port-name-number-or-range</em></span>]...}</span></dt><dd><p>Port(s) used by the client. If omitted, any source port is
          acceptable. Specified as a comma- separated list of port names, port
          numbers or port ranges.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>Unless you really understand IP, you should leave this
            column empty or place a dash (<span class="bold"><strong>-</strong></span>)
            in the column. Most people who try to use this column get it
            wrong.</p></div><div class="blockquote"><blockquote class="blockquote"><p>If you don't want to restrict client ports but need to
            specify an <span class="bold"><strong>ORIGINAL DEST</strong></span> in the
            next column, then place "-" in this column.</p><p>If your kernel contains multi-port match support, then only
            a single Netfilter rule will be generated if in this list and the
            <span class="bold"><strong>DEST PORT(S)</strong></span> list above:</p><p>1. There are 15 or less ports listed.</p><p>2. No port ranges are included or your kernel and iptables
            contain extended multiport match support.</p><p>Otherwise, unless you are using <a class="ulink" href="../Shorewall-perl.html" target="_self">Shorewall-perl</a>, a separate
            rule will be generated for each port. Shorewall-perl does not
            automatically break up lists into individual rules.</p></blockquote></div></dd><dt><span class="term"><span class="bold"><strong>ORIGINAL DEST</strong></span> (Optional) -
        [<span class="bold"><strong>-</strong></span>|<span class="emphasis"><em>address</em></span>[,<span class="emphasis"><em>address</em></span>]...[<span class="emphasis"><em>exclusion</em></span>]|<span class="emphasis"><em>exclusion</em></span>]</span></dt><dd><p>If ACTION is <span class="bold"><strong>DNAT</strong></span>[<span class="bold"><strong>-</strong></span>] or <span class="bold"><strong>REDIRECT</strong></span>[<span class="bold"><strong>-</strong></span>]
          then if this column is included and is different from the IP address
          given in the <span class="bold"><strong>SERVER</strong></span> column, then
          connections destined for that address will be forwarded to the IP
          and port specified in the <span class="bold"><strong>DEST</strong></span>
          column.</p><p>A comma-separated list of addresses may also be used. This is
          most useful with the <span class="bold"><strong>REDIRECT</strong></span>
          target where you want to redirect traffic destined for particular
          set of hosts. Finally, if the list of addresses begins with "!"
          (<span class="emphasis"><em>exclusion</em></span>) then the rule will be followed only
          if the original destination address in the connection request does
          not match any of the addresses listed.</p><p>For other actions, this column may be included and may contain
          one or more addresses (host or network) separated by commas. Address
          ranges are not allowed. When this column is supplied, rules are
          generated that require that the original destination address matches
          one of the listed addresses. This feature is most useful when you
          want to generate a filter rule that corresponds to a <span class="bold"><strong>DNAT-</strong></span> or <span class="bold"><strong>REDIRECT-</strong></span> rule. In this usage, the list of
          addresses should not begin with "!".</p><p>It is also possible to specify a set of addresses then exclude
          part of those addresses. For example, <span class="bold"><strong>192.168.1.0/24!192.168.1.16/28</strong></span> specifies the
          addresses 192.168.1.0-182.168.1.15 and 192.168.1.32-192.168.1.255.
          See <a class="ulink" href="shorewall-exclusion.html" target="_self">shorewall-exclusion</a>(5).</p><p>See <a class="ulink" href="../PortKnocking.html" target="_self">http://shorewall.net/PortKnocking.html</a>
          for an example of using an entry in this column with a user-defined
          action rule.</p></dd><dt><span class="term"><span class="bold"><strong>RATE LIMIT</strong></span> (Optional) -
        [<span class="bold"><strong>-</strong></span>|<span class="emphasis"><em>rate</em></span><span class="bold"><strong>/</strong></span>{<span class="bold"><strong>sec</strong></span>|<span class="bold"><strong>min</strong></span>}[:<span class="emphasis"><em>burst</em></span>]</span></dt><dd><p>You may rate-limit the rule by placing a value in this
          column:</p><p><span class="emphasis"><em>rate</em></span> is the number of connections per
          interval (<span class="bold"><strong>sec</strong></span> or <span class="bold"><strong>min</strong></span>) and <span class="emphasis"><em>burst</em></span> is the
          largest burst permitted. If no <span class="emphasis"><em>burst</em></span> is given,
          a value of 5 is assumed. There may be no no whitespace embedded in
          the specification.</p><p>Example: <span class="bold"><strong>10/sec:20</strong></span></p></dd><dt><span class="term"><span class="bold"><strong>USER/GROUP</strong></span> (Optional) -
        [<span class="bold"><strong>!</strong></span>][<span class="emphasis"><em>user-name-or-number</em></span>][<span class="bold"><strong>:</strong></span><span class="emphasis"><em>group-name-or-number</em></span>][<span class="bold"><strong>+</strong></span><span class="emphasis"><em>program-name</em></span>]</span></dt><dd><p>This column may only be non-empty if the SOURCE is the
          firewall itself.</p><p>When this column is non-empty, the rule applies only if the
          program generating the output is running under the effective
          <span class="emphasis"><em>user</em></span> and/or <span class="emphasis"><em>group</em></span>
          specified (or is NOT running under that id if "!" is given).</p><p>Examples:</p><div class="variablelist"><dl><dt><span class="term">joe</span></dt><dd><p>program must be run by joe</p></dd><dt><span class="term">:kids</span></dt><dd><p>program must be run by a member of the 'kids'
                group</p></dd><dt><span class="term">!:kids</span></dt><dd><p>program must not be run by a member of the 'kids'
                group</p></dd><dt><span class="term">+upnpd</span></dt><dd><p>#program named upnpd</p><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p>The ability to specify a program name was removed from
                  Netfilter in kernel version 2.6.14.</p></div></dd></dl></div></dd><dt><span class="term"><span class="bold"><strong>MARK</strong></span> - [<span class="bold"><strong>!</strong></span>]<span class="emphasis"><em>value</em></span>[/<span class="emphasis"><em>mask</em></span>][<span class="bold"><strong>:C</strong></span>]</span></dt><dd><p>Defines a test on the existing packet or connection mark. The
          rule will match only if the test returns true.</p><p>If you don't want to define a test but need to specify
          anything in the following columns, place a "-" in this field.</p><div class="variablelist"><dl><dt><span class="term">!</span></dt><dd><p>Inverts the test (not equal)</p></dd><dt><span class="term"><span class="emphasis"><em>value</em></span></span></dt><dd><p>Value of the packet or connection mark.</p></dd><dt><span class="term"><span class="emphasis"><em>mask</em></span></span></dt><dd><p>A mask to be applied to the mark before testing.</p></dd><dt><span class="term"><span class="bold"><strong>:C</strong></span></span></dt><dd><p>Designates a connection mark. If omitted, the packet
                mark's value is tested. This option is only supported by
                Shorewall-perl.</p></dd></dl></div></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="id259956"></a><h2>Restrictions</h2><p>Unless you are using <a class="ulink" href="../Shorewall-perl.html" target="_self">Shorewall-perl</a> and your
    iptables/kernel have <em class="firstterm">Repeat Match</em> support (see the
    output of <span class="command"><strong>shorewall show capabilities</strong></span>), if you specify
    a list of DEST PORT(S), then you may not specify SOURCE PORT(S) and vice
    versa.</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="id259980"></a><h2>Example</h2><div class="variablelist"><dl><dt><span class="term">Example 1:</span></dt><dd><p>Accept SMTP requests from the DMZ to the internet</p><pre class="programlisting">         #ACTION SOURCE  DEST PROTO      DEST    SOURCE  ORIGINAL
         #                               PORT    PORT(S) DEST
         ACCEPT  dmz     net       tcp   smtp</pre></dd><dt><span class="term">Example 2:</span></dt><dd><p>Forward all ssh and http connection requests from the internet
          to local system 192.168.1.3</p><pre class="programlisting">        #ACTION SOURCE  DEST            PROTO   DEST    SOURCE  ORIGINAL
        #                                       PORT    PORT(S) DEST
        DNAT    net     loc:192.168.1.3 tcp     ssh,http</pre></dd><dt><span class="term">Example 3:</span></dt><dd><p>Forward all http connection requests from the internet to
          local system 192.168.1.3 with a limit of 3 per second and a maximum
          burst of 10</p><pre class="programlisting">        #ACTION SOURCE DEST            PROTO  DEST  SOURCE  ORIGINAL RATE
        #                                     PORT  PORT(S) DEST     LIMIT
        DNAT    net    loc:192.168.1.3 tcp    http  -       -        3/sec:10</pre></dd><dt><span class="term">Example 4:</span></dt><dd><p>Redirect all locally-originating www connection requests to
          port 3128 on the firewall (Squid running on the firewall system)
          except when the destination address is 192.168.2.2</p><pre class="programlisting">        #ACTION  SOURCE DEST      PROTO DEST    SOURCE  ORIGINAL
        #                               PORT    PORT(S) DEST
        REDIRECT loc    3128      tcp   www      -      !192.168.2.2</pre></dd><dt><span class="term">Example 5:</span></dt><dd><p>All http requests from the internet to address 130.252.100.69
          are to be forwarded to 192.168.1.3</p><pre class="programlisting">        #ACTION  SOURCE DEST            PROTO   DEST    SOURCE  ORIGINAL
        #                                       PORT    PORT(S) DEST
        DNAT      net   loc:192.168.1.3 tcp     80      -       130.252.100.69</pre></dd><dt><span class="term">Example 6:</span></dt><dd><p>You want to accept SSH connections to your firewall only from
          internet IP addresses 130.252.100.69 and 130.252.100.70</p><pre class="programlisting">        #ACTION  SOURCE DEST            PROTO   DEST    SOURCE  ORIGINAL
        #                                       PORT    PORT(S) DEST
        ACCEPT   net:130.252.100.69,130.252.100.70 $FW \
                                        tcp     22</pre></dd><dt><span class="term">Example 7:</span></dt><dd><p>You wish to accept connections from the internet to your
          firewall on port 2222 and you want to forward them to local system
          192.168.1.3, port 22</p><pre class="programlisting">        #ACTION  SOURCE DEST                PROTO   DEST    SOURCE  ORIGINAL
        #                                           PORT    PORT(S) DEST
        DNAT     net    loc:192.168.1.3:22  tcp     2222</pre></dd><dt><span class="term">Example 8:</span></dt><dd><p>You want to redirect connection requests to port 80 randomly
          to the port range 81-90.</p><pre class="programlisting">        #ACTION  SOURCE DEST                PROTO DEST    SOURCE  ORIGINAL
        #                                         PORT    PORT(S) DEST
        REDIRECT net    $FW::81-90:random   tcp   www</pre></dd><dt><span class="term">Example 9:</span></dt><dd><p>Shorewall does not impose as much structure on the Netfilter
          rules in the 'nat' table as it does on those in the filter table. As
          a consequence, care must be exercised when using DNAT and REDIRECT
          rules with zones defined with wildcard interfaces (those ending with
          '+'. Here is an example:</p><p><a class="ulink" href="shorewall-zones.html" target="_self">shorewall-zones</a>(8):</p><pre class="programlisting">        #ZONE       TYPE    OPTIONS
        fw          firewall
        net         ipv4
        dmz         ipv4
        loc         ipv4</pre><p><a class="ulink" href="shorewall-interfaces.html" target="_self">shorewall-interfaces</a>(8):</p><pre class="programlisting">        #ZONE       INTERFACE       BROADCAST      OPTIONS
        net         ppp0
        loc         eth1            detect
        dmz         eth2            detect
        -           ppp+                           # Addresses are assigned from 192.168.3.0/24</pre><p><a class="ulink" href="shorewall-hosts.html" target="_self">shorewall-host</a>(8):</p><pre class="programlisting">        #ZONE       HOST(S)              OPTIONS
        loc         ppp+:192.168.3.0/24</pre><p>rules:</p><pre class="programlisting">        #ACTION     SOURCE          DEST       PROTO       DEST
        #                                                  PORT(S)
        REDIRECT    loc             3128       tcp         80                                                   </pre><p>Note that it would have been tempting to simply define the
          loc zone entirely in shorewall-interfaces(8):</p><pre class="programlisting">        #******************* INCORRECT *****************
        #ZONE       INTERFACE       BROADCAST      OPTIONS
        net         ppp0
        loc         eth1            detect
        loc         ppp+
        dmz         eth2</pre><p>This would have made it impossible to run a
          internet-accessible web server in the DMZ because all traffic
          entering ppp+ interfaces would have been redirected to port 3128 on
          the firewall and there would have been no net-&gt;fw ACCEPT rule for
          that traffic.</p></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="id260222"></a><h2>FILES</h2><p>/etc/shorewall/rules</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="id260232"></a><h2>See ALSO</h2><p>shorewall(8), shorewall-accounting(5), shorewall-actions(5),
    shorewall-blacklist(5), shorewall-hosts(5), shorewall-interfaces(5),
    shorewall-ipsec(5), shorewall-maclist(5), shorewall-masq(5),
    shorewall-nat(5), shorewall-netmap(5), shorewall-params(5),
    shorewall-policy(5), shorewall-providers(5), shorewall-proxyarp(5),
    shorewall-route_routes(5), shorewall-routestopped(5), shorewall.conf(5),
    shorewall-tcclasses(5), shorewall-tcdevices(5), shorewall-tcrules(5),
    shorewall-tos(5), shorewall-tunnels(5), shorewall-zones(5)</p></div></div></body></html>