Sophie

Sophie

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

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-masq</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>masq — Shorewall Masquerade/SNAT definition file</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">/etc/shorewall/masq</code> </p></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="id257199"></a><h2>Description</h2><p>Use this file to define dynamic NAT (Masquerading) and to define
    Source NAT (SNAT).</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>The entries in this file are order-sensitive. The first entry that
      matches a particular connection will be the one that is used.</p></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>If you have more than one ISP, adding entries to this file will
      *not* force connections to go out through a particular ISP. You must use
      PREROUTING entries in <a class="ulink" href="shorewall-tcrules.tcml" target="_self">shorewall-tcrules</a>(5) to do
      that.</p></div><p>The columns in the file are as follows.</p><div class="variablelist"><dl><dt><span class="term"><span class="bold"><strong>INTERFACE</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>digit</em></span>]][<span class="bold"><strong>:</strong></span>[<span class="emphasis"><em>address</em></span>[<span class="bold"><strong>,</strong></span><span class="emphasis"><em>address</em></span>]...[<span class="emphasis"><em>exclusion</em></span>]]</span></dt><dd><p>Outgoing <span class="emphasis"><em>interface</em></span>. This is usually your
          internet interface. If ADD_SNAT_ALIASES=Yes in <a class="ulink" href="shorewall.conf.html" target="_self">shorewall.conf</a>(5), you may add ":"
          and a <span class="emphasis"><em>digit</em></span> to indicate that you want the alias
          added with that name (e.g., eth0:0). This will allow the alias to be
          displayed with ifconfig. <span class="bold"><strong>That is the only use
          for the alias name; it may not appear in any other place in your
          Shorewall configuratio</strong></span>n.</p><p>The interface may be qualified by adding the character ":"
          followed by a comma-separated list of destination host or subnet
          addresses to indicate that you only want to change the source IP
          address for packets being sent to those particular destinations.
          Exclusion is allowed (see <a class="ulink" href="shorewall-exclusion.html" target="_self">shorewall-exclusion</a>(5)).</p><p>If you wish to inhibit the action of ADD_SNAT_ALIASES for this
          entry then include the ":" but omit the digit:</p><pre class="programlisting">        eth0:
        eth2::192.0.2.32/27</pre><p>Normally Masq/SNAT rules are evaluated after those for
          one-to-one NAT (defined in <a class="ulink" href="shorewall-nat.html" target="_self">shorewall-nat</a>(5)). If you want the
          rule to be applied before one-to-one NAT rules, prefix the interface
          name with "+":</p><pre class="programlisting">        +eth0
        +eth0:192.0.2.32/27
        +eth0:2</pre><p>This feature should only be required if you need to insert
          rules in this file that preempt entries in <a class="ulink" href="shorewall-nat.html" target="_self">shorewall-nat</a>(5).</p></dd><dt><span class="term"><span class="bold"><strong>SOURCE</strong></span> (Formerly called SUBNET)
        -
        {<span class="emphasis"><em>interface</em></span>[[:]<span class="emphasis"><em>exclusion</em></span>]|<span class="emphasis"><em>address</em></span>[<span class="bold"><strong>,</strong></span><span class="emphasis"><em>address</em></span>][<span class="emphasis"><em>exclusion</em></span>]}</span></dt><dd><p>Set of hosts that you wish to masquerade. You can specify this
          as an <span class="emphasis"><em>address</em></span> (net or host) or as an
          <span class="emphasis"><em>interface</em></span>. If you give the name of an
          interface, the interface must be up before you start the firewall
          (Shorewall will use your main routing table to determine the
          appropriate addresses to masquerade).</p><p>In order to exclude a address of the specified SOURCE, you may
          append an <span class="emphasis"><em>exclusion</em></span> ("!" and a comma-separated
          list of IP addresses (host or net) that you wish to exclude (see
          <a class="ulink" href="shorewall-exclusion.html" target="_self">shorewall-exclusion</a>(5))).
          Note that with Shorewall-perl, a colon (":") must appear between an
          <em class="replaceable"><code>interface</code></em> name and the
          <em class="replaceable"><code>exclusion</code></em>;</p><p>Example (shorewall-shell):
          eth1!192.168.1.4,192.168.32.0/27</p><p>Example (shorewall-perl):
          eth1:!192.168.1.4,192.168.32.0/27</p><p>In that example traffic from eth1 would be masqueraded unless
          it came from 192.168.1.4 or 196.168.32.0/27</p></dd><dt><span class="term"><span class="bold"><strong>ADDRESS</strong></span> (Optional) - [<span class="bold"><strong>-</strong></span>|[<span class="bold"><strong>SAME:</strong></span>[<span class="bold"><strong>nodst:</strong></span>]][<span class="emphasis"><em>address-or-address-range</em></span>[,<span class="emphasis"><em>address-or-address-range</em></span>]...][:<span class="emphasis"><em>lowport</em></span><span class="bold"><strong>-</strong></span><span class="emphasis"><em>highport</em></span>][<span class="bold"><strong>:random</strong></span>]|<span class="bold"><strong>detect</strong></span>|<span class="bold"><strong>random</strong></span>]</span></dt><dd><p>If you specify an address here, SNAT will be used and this
          will be the source address. If ADD_SNAT_ALIASES is set to Yes or yes
          in <a class="ulink" href="shorewall.conf.html" target="_self">shorewall.conf</a>(5) then
          Shorewall will automatically add this address to the INTERFACE named
          in the first column.</p><p>You may also specify a range of up to 256 IP addresses if you
          want the SNAT address to be assigned from that range in a
          round-robin fashion by connection. The range is specified by
          <span class="emphasis"><em>first.ip.in.range</em></span>-<span class="emphasis"><em>last.ip.in.range</em></span>.
          Beginning with Shorewall 4.0.6, you may follow the port range
          with<span class="bold"><strong> :random</strong></span> in which case
          assignment of ports from the list will be random. <span class="bold"><strong>random</strong></span> may also be specified by itself in
          this column in which case random local port assignments are made for
          the outgoing connections.</p><p>Example: 206.124.146.177-206.124.146.180</p><p>You may also use the special value "detect" which causes
          Shorewall to determine the IP addresses configured on the interface
          named in the INTERFACES column and substitute them in this
          column.</p><p>Finally, you may also specify a comma-separated list of ranges
          and/or addresses in this column.</p><p>This column may not contain DNS Names.</p><p>Normally, Netfilter will attempt to retain the source port
          number. You may cause netfilter to remap the source port by
          following an address or range (if any) by ":" and a port range with
          the format
          <span class="emphasis"><em>lowport</em></span>-<span class="emphasis"><em>highport</em></span>. If this
          is done, you must specify "tcp" or "udp" in the PROTO column.</p><p>Examples:</p><pre class="programlisting">        192.0.2.4:5000-6000
        :4000-5000</pre><p>You can invoke the SAME target rather than the SNAT target by
          prefixing the column contents with <code class="option">SAME:</code>.</p><p>SAME works like SNAT with the exception that the same local IP
          address is assigned to each connection from a local address to a
          given remote address.</p><p>If the <code class="option">nodst:</code> option is included, then the
          same source address is used for a given internal system regardless
          of which remote system is involved.</p><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>Support for the SAME target is scheduled for removal from
              the Linux kernel in 2008.</p></div><p>If you want to leave this column empty but you need to specify
          the next column then place a hyphen ("-") here.</p></dd><dt><span class="term"><span class="bold"><strong>PROTO</strong></span> (Optional) - {<span class="bold"><strong>-</strong></span>|<span class="emphasis"><em>protocol-name</em></span>|<span class="emphasis"><em>protocol-number</em></span>}</span></dt><dd><p>If you wish to restrict this entry to a particular protocol
          then enter the protocol name (from protocols(5)) or number
          here.</p></dd><dt><span class="term"><span class="bold"><strong>PORT(S)</strong></span> (Optional) -
        [<span class="emphasis"><em>port-name-or-number</em></span>[,<span class="emphasis"><em>port-name-or-number</em></span>]...]</span></dt><dd><p>If the PROTO column specifies TCP (protocol 6) or UDP
          (protocol 17) then you may list one or more port numbers (or names
          from services(5)) separated by commas or you may list a single port
          range
          (<span class="emphasis"><em>lowport</em></span>:<span class="emphasis"><em>highport</em></span>).</p><p>Where a comma-separated list is given, your kernel and
          iptables must have multiport match support and a maximum of 15 ports
          may be listed.</p></dd><dt><span class="term"><span class="bold"><strong>IPSEC</strong></span> (Optional) -
        [<span class="emphasis"><em>option</em></span>[<span class="bold"><strong>,</strong></span><span class="emphasis"><em>option</em></span>]...]</span></dt><dd><p>If you specify a value other than "-" in this column, you must
          be running kernel 2.6 and your kernel and iptables must include
          policy match support.</p><p>Comma-separated list of options from the following. Only
          packets that will be encrypted via an SA that matches these options
          will have their source address changed.</p><div class="variablelist"><dl><dt><span class="term"><span class="bold"><strong>reqid=</strong></span><span class="emphasis"><em>number</em></span></span></dt><dd><p>where <span class="emphasis"><em>number</em></span> is specified using
                setkey(8) using the 'unique:<span class="emphasis"><em>number</em></span> option
                for the SPD level.</p></dd><dt><span class="term"><span class="bold"><strong>spi=</strong></span>&lt;number&gt;</span></dt><dd><p>where <span class="emphasis"><em>number</em></span> is the SPI of the SA
                used to encrypt/decrypt packets.</p></dd><dt><span class="term"><span class="bold"><strong>proto=</strong></span><span class="bold"><strong>ah</strong></span>|<span class="bold"><strong>esp</strong></span>|<span class="bold"><strong>ipcomp</strong></span></span></dt><dd><p>IPSEC Encapsulation Protocol</p></dd><dt><span class="term"><span class="bold"><strong>mss=</strong></span><span class="emphasis"><em>number</em></span></span></dt><dd><p>sets the MSS field in TCP packets</p></dd><dt><span class="term"><span class="bold"><strong>mode=</strong></span><span class="bold"><strong>transport</strong></span>|<span class="bold"><strong>tunnel</strong></span></span></dt><dd><p>IPSEC mode</p></dd><dt><span class="term"><span class="bold"><strong>tunnel-src=</strong></span><span class="emphasis"><em>address</em></span>[/<span class="emphasis"><em>mask</em></span>]</span></dt><dd><p>only available with mode=tunnel</p></dd><dt><span class="term"><span class="bold"><strong>tunnel-dst=</strong></span><span class="emphasis"><em>address</em></span>[/<span class="emphasis"><em>mask</em></span>]</span></dt><dd><p>only available with mode=tunnel</p></dd><dt><span class="term"><span class="bold"><strong>strict</strong></span></span></dt><dd><p>Means that packets must match all rules.</p></dd><dt><span class="term"><span class="bold"><strong>next</strong></span></span></dt><dd><p>Separates rules; can only be used with strict</p></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="id258182"></a><h2>Examples</h2><div class="variablelist"><dl><dt><span class="term">Example 1:</span></dt><dd><p>You have a simple masquerading setup where eth0 connects to a
          DSL or cable modem and eth1 connects to your local network with
          subnet 192.168.0.0/24.</p><p>Your entry in the file can be either:</p><pre class="programlisting">        #INTERFACE   SOURCE
        eth0         eth1</pre><p>or</p><pre class="programlisting">        #INTERFACE   SOURCE
        eth0    192.168.0.0/24</pre></dd><dt><span class="term">Example 2:</span></dt><dd><p>You add a router to your local network to connect subnet
          192.168.1.0/24 which you also want to masquerade. You then add a
          second entry for eth0 to this file:</p><pre class="programlisting">        #INTERFACE   SOURCE
        eth0         192.168.1.0/24</pre></dd><dt><span class="term">Example 3:</span></dt><dd><p>You have an IPSEC tunnel through ipsec0 and you want to
          masquerade packets coming from 192.168.1.0/24 but only if these
          packets are destined for hosts in 10.1.1.0/24:</p><pre class="programlisting">        #INTERFACE              SOURCE
        ipsec0:10.1.1.0/24      196.168.1.0/24</pre></dd><dt><span class="term">Example 4:</span></dt><dd><p>You want all outgoing traffic from 192.168.1.0/24 through eth0
          to use source address 206.124.146.176 which is NOT the primary
          address of eth0. You want 206.124.146.176 to be added to eth0 with
          name eth0:0.</p><pre class="programlisting">        #INTERFACE              SOURCE          ADDRESS
        eth0:0                  192.168.1.0/24  206.124.146.176</pre></dd><dt><span class="term">Example 5:</span></dt><dd><p>You want all outgoing SMTP traffic entering the firewall on
          eth1 to be sent from eth0 with source IP address 206.124.146.177.
          You want all other outgoing traffic from eth1 to be sent from eth0
          with source IP address 206.124.146.176.</p><pre class="programlisting">        #INTERFACE   SOURCE  ADDRESS         PROTO   PORT(S)
        eth0         eth1    206.124.146.177 tcp     smtp
        eth0         eth1    206.124.146.176</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>The order of the above two rules is significant!</p></div></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="id258303"></a><h2>FILES</h2><p>/etc/shorewall/masq</p></div><div class="refsect1" lang="en" xml:lang="en"><a id="id258313"></a><h2>See ALSO</h2><p>shorewall(8), shorewall-accounting(5), shorewall-actions(5),
    shorewall-blacklist(5), shorewall-exclusion(5), shorewall-hosts(5),
    shorewall-interfaces(5), shorewall-ipsec(5), shorewall-maclist(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-rules(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>