2006-11-15 21:04:33 +01:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
2008-11-25 20:09:36 +01:00
|
|
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
|
2006-11-15 21:04:33 +01:00
|
|
|
<refentry>
|
|
|
|
<refmeta>
|
|
|
|
<refentrytitle>shorewall-masq</refentrytitle>
|
|
|
|
|
|
|
|
<manvolnum>5</manvolnum>
|
2014-01-16 17:32:57 +01:00
|
|
|
|
|
|
|
<refmiscinfo>Configuration Files</refmiscinfo>
|
2006-11-15 21:04:33 +01:00
|
|
|
</refmeta>
|
|
|
|
|
|
|
|
<refnamediv>
|
|
|
|
<refname>masq</refname>
|
|
|
|
|
|
|
|
<refpurpose>Shorewall Masquerade/SNAT definition file</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
<refsynopsisdiv>
|
|
|
|
<cmdsynopsis>
|
|
|
|
<command>/etc/shorewall/masq</command>
|
|
|
|
</cmdsynopsis>
|
|
|
|
</refsynopsisdiv>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
|
|
|
|
<para>Use this file to define dynamic NAT (Masquerading) and to define
|
|
|
|
Source NAT (SNAT).</para>
|
|
|
|
|
|
|
|
<warning>
|
|
|
|
<para>The entries in this file are order-sensitive. The first entry that
|
|
|
|
matches a particular connection will be the one that is used.</para>
|
|
|
|
</warning>
|
|
|
|
|
|
|
|
<warning>
|
2010-01-18 18:00:13 +01:00
|
|
|
<para>If you have more than one ISP link, adding entries to this file
|
|
|
|
will <emphasis role="bold">not</emphasis> force connections to go out
|
|
|
|
through a particular link. You must use entries in <ulink
|
2014-01-16 17:32:57 +01:00
|
|
|
url="/manpages/shorewall-rtrules.html">shorewall-rtrules</ulink>(5) or
|
|
|
|
PREROUTING entries in <ulink
|
2014-01-12 22:40:03 +01:00
|
|
|
url="/manpages/shorewall-mangle.html">shorewall-mangle</ulink>(5) to do
|
2007-01-14 23:34:51 +01:00
|
|
|
that.</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
</warning>
|
|
|
|
|
|
|
|
<para>The columns in the file are as follows.</para>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
2010-08-06 01:50:48 +02:00
|
|
|
<term><emphasis role="bold">INTERFACE:DEST</emphasis> - {[<emphasis
|
2008-01-15 03:47:32 +01:00
|
|
|
role="bold">+</emphasis>]<emphasis>interfacelist</emphasis>[<emphasis
|
2006-11-23 00:04:20 +01:00
|
|
|
role="bold">:</emphasis>[<emphasis>digit</emphasis>]][<emphasis
|
2010-08-06 01:50:48 +02:00
|
|
|
role="bold">:</emphasis>[<emphasis>dest-address</emphasis>[<emphasis
|
2012-12-26 16:43:06 +01:00
|
|
|
role="bold">,</emphasis><emphasis>dest-address</emphasis>]...[<emphasis>exclusion</emphasis>]]|[?]COMMENT}</term>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<listitem>
|
2009-07-16 02:50:55 +02:00
|
|
|
<para>Outgoing <emphasis>interfacelist</emphasis>. This may be a
|
|
|
|
comma-separated list of interface names. This is usually your
|
|
|
|
internet interface. If ADD_SNAT_ALIASES=Yes in <ulink
|
2014-01-16 17:32:57 +01:00
|
|
|
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5), you
|
|
|
|
may add ":" and a <emphasis>digit</emphasis> 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. <emphasis role="bold">That
|
|
|
|
is the only use for the alias name; it may not appear in any other
|
|
|
|
place in your Shorewall configuration.</emphasis></para>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
2008-01-20 00:36:27 +01:00
|
|
|
<para>Each interface must match an entry in <ulink
|
2014-01-12 22:40:03 +01:00
|
|
|
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>(5).
|
2009-07-16 02:50:55 +02:00
|
|
|
Shorewall allows loose matches to wildcard entries in <ulink
|
2014-01-16 17:32:57 +01:00
|
|
|
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>(5).
|
|
|
|
For example, <filename class="devicefile">ppp0</filename> in this
|
|
|
|
file will match a <ulink
|
2014-01-12 22:40:03 +01:00
|
|
|
url="/manpages/shorewall-interfaces.html">shorewall-interfaces</ulink>(5)
|
2008-01-20 00:36:27 +01:00
|
|
|
entry that defines <filename
|
|
|
|
class="devicefile">ppp+</filename>.</para>
|
|
|
|
|
2014-01-16 17:32:57 +01:00
|
|
|
<para>Where <ulink url="/4.4/MultiISP.html#Shared">more that one
|
|
|
|
internet provider share a single interface</ulink>, the provider is
|
|
|
|
specified by including the provider name or number in
|
2009-08-12 22:52:56 +02:00
|
|
|
parentheses:</para>
|
|
|
|
|
|
|
|
<programlisting> eth0(Avvanta)</programlisting>
|
|
|
|
|
2013-12-14 00:44:16 +01:00
|
|
|
<para>In that case, you will want to specify the interface's address
|
|
|
|
for that provider in the ADDRESS column.</para>
|
2009-08-12 22:52:56 +02:00
|
|
|
|
2006-11-15 21:04:33 +01:00
|
|
|
<para>The interface may be qualified by adding the character ":"
|
2006-11-23 00:04:20 +01:00
|
|
|
followed by a comma-separated list of destination host or subnet
|
|
|
|
addresses to indicate that you only want to change the source IP
|
2006-11-25 19:06:11 +01:00
|
|
|
address for packets being sent to those particular destinations.
|
2007-01-14 23:34:51 +01:00
|
|
|
Exclusion is allowed (see <ulink
|
2014-01-16 17:32:57 +01:00
|
|
|
url="/manpages/shorewall-exclusion.html">shorewall-exclusion</ulink>(5))
|
|
|
|
as are ipset names preceded by a plus sign '+';</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<para>If you wish to inhibit the action of ADD_SNAT_ALIASES for this
|
|
|
|
entry then include the ":" but omit the digit:</para>
|
|
|
|
|
2009-08-12 22:52:56 +02:00
|
|
|
<programlisting> eth0(Avvanta):
|
2006-11-15 21:04:33 +01:00
|
|
|
eth2::192.0.2.32/27</programlisting>
|
|
|
|
|
|
|
|
<para>Normally Masq/SNAT rules are evaluated after those for
|
2007-01-14 23:34:51 +01:00
|
|
|
one-to-one NAT (defined in <ulink
|
2014-01-16 17:32:57 +01:00
|
|
|
url="/manpages/shorewall-nat.html">shorewall-nat</ulink>(5)). If you
|
|
|
|
want the rule to be applied before one-to-one NAT rules, prefix the
|
|
|
|
interface name with "+":</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<programlisting> +eth0
|
|
|
|
+eth0:192.0.2.32/27
|
|
|
|
+eth0:2</programlisting>
|
|
|
|
|
|
|
|
<para>This feature should only be required if you need to insert
|
2007-01-14 23:34:51 +01:00
|
|
|
rules in this file that preempt entries in <ulink
|
2014-01-12 22:40:03 +01:00
|
|
|
url="/manpages/shorewall-nat.html">shorewall-nat</ulink>(5).</para>
|
2009-03-20 17:47:27 +01:00
|
|
|
|
|
|
|
<para>Comments may be attached to Netfilter rules generated from
|
|
|
|
entries in this file through the use of COMMENT lines. These lines
|
|
|
|
begin with the word COMMENT; the remainder of the line is treated as
|
|
|
|
a comment which is attached to subsequent rules until another
|
|
|
|
COMMENT line is found or until the end of the file is reached. To
|
|
|
|
stop adding comments to rules, use a line with only the word
|
|
|
|
COMMENT.</para>
|
2012-12-23 00:47:03 +01:00
|
|
|
|
|
|
|
<note>
|
|
|
|
<para>Beginning with Shorewall 4.5.11, ?COMMENT is a synonym for
|
|
|
|
COMMENT and is preferred.</para>
|
|
|
|
</note>
|
2013-12-14 00:44:16 +01:00
|
|
|
|
|
|
|
<para>Beginning with Shorewall 4.6.0, a new syntax is also accepted.
|
|
|
|
With the exception of the leading '+', the interfacelist and
|
|
|
|
qualifiers may appear within the parentheses of <emphasis
|
|
|
|
role="bold">INLINE</emphasis>(...).</para>
|
|
|
|
|
|
|
|
<para>Example:</para>
|
|
|
|
|
|
|
|
<programlisting> +INLINE(eth0)</programlisting>
|
|
|
|
|
|
|
|
<para>When this is done, you may augment the rule generated by
|
|
|
|
Shorewall with iptables matches of your own. These matches appear
|
|
|
|
after a semicolon (';') at the end of the line.</para>
|
|
|
|
|
|
|
|
<para>See example 8 below.</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2014-06-16 16:27:05 +02:00
|
|
|
<term><emphasis role="bold">SOURCE</emphasis> (Formerly called SUBNET
|
|
|
|
- Optional) -
|
|
|
|
[<emphasis>interface</emphasis>|<emphasis>address</emphasis>[<emphasis
|
|
|
|
role="bold">,</emphasis><emphasis>address</emphasis>][<emphasis>exclusion</emphasis>]]</term>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Set of hosts that you wish to masquerade. You can specify this
|
2006-11-23 00:04:20 +01:00
|
|
|
as an <emphasis>address</emphasis> (net or host) or as an
|
2009-06-17 21:03:05 +02:00
|
|
|
<emphasis>interface</emphasis> (use of an
|
|
|
|
<emphasis>interface</emphasis> is deprecated). If you give the name
|
|
|
|
of an interface, the interface must be up before you start the
|
|
|
|
firewall and the Shorewall rules compiler will warn you of that
|
|
|
|
fact. (Shorewall will use your main routing table to determine the
|
|
|
|
appropriate addresses to masquerade).</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
2012-02-18 17:17:14 +01:00
|
|
|
<para>The preferred way to specify the SOURCE is to supply one or
|
|
|
|
more host or network addresses separated by comma. You may use ipset
|
|
|
|
names preceded by a plus sign (+) to specify a set of hosts.</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2008-07-10 15:33:54 +02:00
|
|
|
<term><emphasis role="bold">ADDRESS</emphasis> (Optional) - [<emphasis
|
2008-08-20 01:28:47 +02:00
|
|
|
role="bold">-</emphasis>|<emphasis
|
2009-04-01 03:31:04 +02:00
|
|
|
role="bold">NONAT</emphasis>|[<emphasis>address-or-address-range</emphasis>[,<emphasis>address-or-address-range</emphasis>]...][:<emphasis>lowport</emphasis><emphasis
|
2007-11-15 21:53:23 +01:00
|
|
|
role="bold">-</emphasis><emphasis>highport</emphasis>][<emphasis
|
2009-08-15 17:15:38 +02:00
|
|
|
role="bold">:random</emphasis>][:persistent]|<emphasis
|
2007-11-15 21:53:23 +01:00
|
|
|
role="bold">detect</emphasis>|<emphasis
|
|
|
|
role="bold">random</emphasis>]</term>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>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
|
2014-01-16 17:32:57 +01:00
|
|
|
in <ulink
|
|
|
|
url="/manpages/shorewall.conf.html">shorewall.conf</ulink>(5) then
|
2007-01-14 23:34:51 +01:00
|
|
|
Shorewall will automatically add this address to the INTERFACE named
|
|
|
|
in the first column.</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<para>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
|
2007-01-28 19:28:13 +01:00
|
|
|
round-robin fashion by connection. The range is specified by
|
2007-11-15 21:53:23 +01:00
|
|
|
<emphasis>first.ip.in.range</emphasis>-<emphasis>last.ip.in.range</emphasis>.
|
2009-07-16 02:50:55 +02:00
|
|
|
You may follow the port range with<emphasis role="bold">
|
|
|
|
:random</emphasis> in which case assignment of ports from the list
|
|
|
|
will be random. <emphasis role="bold">random</emphasis> may also be
|
|
|
|
specified by itself in this column in which case random local port
|
|
|
|
assignments are made for the outgoing connections.</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<para>Example: 206.124.146.177-206.124.146.180</para>
|
|
|
|
|
2009-08-15 17:15:38 +02:00
|
|
|
<para>You may follow the port range (or <emphasis
|
|
|
|
role="bold">:random</emphasis>) with <emphasis
|
|
|
|
role="bold">:persistent</emphasis>. This is only useful when an
|
|
|
|
address range is specified and causes a client to be given the same
|
|
|
|
source/destination IP pair. This feature replaces the SAME modifier
|
|
|
|
which was removed from Shorewall in version 4.4.0. Unlike <emphasis
|
|
|
|
role="bold">random</emphasis>, <emphasis
|
|
|
|
role="bold">persistent</emphasis> may not be used by itself.</para>
|
|
|
|
|
2006-11-15 21:04:33 +01:00
|
|
|
<para>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.</para>
|
|
|
|
|
|
|
|
<para>Finally, you may also specify a comma-separated list of ranges
|
|
|
|
and/or addresses in this column.</para>
|
|
|
|
|
|
|
|
<para>This column may not contain DNS Names.</para>
|
|
|
|
|
|
|
|
<para>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
|
|
|
|
<emphasis>lowport</emphasis>-<emphasis>highport</emphasis>. If this
|
|
|
|
is done, you must specify "tcp" or "udp" in the PROTO column.</para>
|
|
|
|
|
|
|
|
<para>Examples:</para>
|
|
|
|
|
|
|
|
<programlisting> 192.0.2.4:5000-6000
|
|
|
|
:4000-5000</programlisting>
|
|
|
|
|
2008-08-20 01:28:47 +02:00
|
|
|
<para>If you simply place <emphasis role="bold">NONAT</emphasis> in
|
|
|
|
this column, no rewriting of the source IP address or port number
|
2008-08-22 18:11:52 +02:00
|
|
|
will be performed. This is useful if you want particular traffic to
|
|
|
|
be exempt from the entries that follow in the file.</para>
|
2008-08-20 01:28:47 +02:00
|
|
|
|
2006-11-15 21:04:33 +01:00
|
|
|
<para>If you want to leave this column empty but you need to specify
|
|
|
|
the next column then place a hyphen ("-") here.</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2008-07-10 15:33:54 +02:00
|
|
|
<term><emphasis role="bold">PROTO</emphasis> (Optional) - {<emphasis
|
2014-01-03 18:23:14 +01:00
|
|
|
role="bold">-</emphasis>|[!]{<emphasis>protocol-name</emphasis>|<emphasis>protocol-number</emphasis>}[,...]|+<replaceable>ipset</replaceable>}</term>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>If you wish to restrict this entry to a particular protocol
|
|
|
|
then enter the protocol name (from protocols(5)) or number
|
|
|
|
here.</para>
|
2013-01-08 01:06:54 +01:00
|
|
|
|
|
|
|
<para>Beginning with Shorewall 4.5.12, this column can accept a
|
|
|
|
comma-separated list of protocols.</para>
|
2014-01-03 18:23:14 +01:00
|
|
|
|
|
|
|
<para>Beginning with Shorewall 4.6.0, an
|
|
|
|
<replaceable>ipset</replaceable> name can be specified in this
|
|
|
|
column. This is intended to be used with
|
|
|
|
<firstterm>bitmap:port</firstterm> ipsets.</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2008-07-10 15:33:54 +02:00
|
|
|
<term><emphasis role="bold">PORT(S)</emphasis> (Optional) -
|
2014-01-03 18:23:14 +01:00
|
|
|
{-|[!]<emphasis>port-name-or-number</emphasis>[,<emphasis>port-name-or-number</emphasis>]...|+<replaceable>ipset</replaceable>}</term>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<listitem>
|
2010-03-16 17:42:50 +01:00
|
|
|
<para>If the PROTO column specifies TCP (6), UDP (17), DCCP (33),
|
|
|
|
SCTP (132) or UDPLITE (136) then you may list one or more port
|
2010-11-21 17:48:12 +01:00
|
|
|
numbers (or names from services(5)) or port ranges separated by
|
|
|
|
commas.</para>
|
|
|
|
|
2011-04-21 01:20:42 +02:00
|
|
|
<para>Port ranges are of the form
|
2010-11-21 17:48:12 +01:00
|
|
|
<emphasis>lowport</emphasis>:<emphasis>highport</emphasis>.</para>
|
2014-01-03 18:23:14 +01:00
|
|
|
|
|
|
|
<para>Beginning with Shorewall 4.6.0, an
|
|
|
|
<replaceable>ipset</replaceable> name can be specified in this
|
|
|
|
column. This is intended to be used with
|
|
|
|
<firstterm>bitmap:port</firstterm> ipsets.</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2008-07-10 15:33:54 +02:00
|
|
|
<term><emphasis role="bold">IPSEC</emphasis> (Optional) -
|
2006-11-23 00:04:20 +01:00
|
|
|
[<emphasis>option</emphasis>[<emphasis
|
|
|
|
role="bold">,</emphasis><emphasis>option</emphasis>]...]</term>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>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.</para>
|
|
|
|
|
|
|
|
<para>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.</para>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis
|
|
|
|
role="bold">reqid=</emphasis><emphasis>number</emphasis></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>where <emphasis>number</emphasis> is specified using
|
|
|
|
setkey(8) using the 'unique:<emphasis>number</emphasis> option
|
|
|
|
for the SPD level.</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis role="bold">spi=</emphasis><number></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>where <emphasis>number</emphasis> is the SPI of the SA
|
|
|
|
used to encrypt/decrypt packets.</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis role="bold">proto=</emphasis><emphasis
|
|
|
|
role="bold">ah</emphasis>|<emphasis
|
|
|
|
role="bold">esp</emphasis>|<emphasis
|
|
|
|
role="bold">ipcomp</emphasis></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>IPSEC Encapsulation Protocol</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis
|
|
|
|
role="bold">mss=</emphasis><emphasis>number</emphasis></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>sets the MSS field in TCP packets</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis role="bold">mode=</emphasis><emphasis
|
|
|
|
role="bold">transport</emphasis>|<emphasis
|
|
|
|
role="bold">tunnel</emphasis></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>IPSEC mode</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis
|
|
|
|
role="bold">tunnel-src=</emphasis><emphasis>address</emphasis>[/<emphasis>mask</emphasis>]</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>only available with mode=tunnel</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis
|
|
|
|
role="bold">tunnel-dst=</emphasis><emphasis>address</emphasis>[/<emphasis>mask</emphasis>]</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>only available with mode=tunnel</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis role="bold">strict</emphasis></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Means that packets must match all rules.</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis role="bold">next</emphasis></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Separates rules; can only be used with strict</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2010-07-14 16:01:18 +02:00
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis role="bold">yes</emphasis></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>When used by itself, causes all traffic that will be
|
|
|
|
encrypted/encapsulated to match the rule.</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2006-11-15 21:04:33 +01:00
|
|
|
</variablelist>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2007-05-08 21:05:25 +02:00
|
|
|
|
|
|
|
<varlistentry>
|
2008-07-10 15:33:54 +02:00
|
|
|
<term><emphasis role="bold">MARK</emphasis> - [<emphasis
|
2007-05-08 21:05:25 +02:00
|
|
|
role="bold">!</emphasis>]<emphasis>value</emphasis>[/<emphasis>mask</emphasis>][<emphasis
|
|
|
|
role="bold">:C</emphasis>]</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Defines a test on the existing packet or connection mark. The
|
|
|
|
rule will match only if the test returns true.</para>
|
|
|
|
|
|
|
|
<para>If you don't want to define a test but need to specify
|
|
|
|
anything in the following columns, place a "-" in this field.</para>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term>!</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Inverts the test (not equal)</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis>value</emphasis></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Value of the packet or connection mark.</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis>mask</emphasis></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>A mask to be applied to the mark before testing.</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis role="bold">:C</emphasis></term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Designates a connection mark. If omitted, the packet
|
2009-07-16 02:50:55 +02:00
|
|
|
mark's value is tested.</para>
|
2007-05-08 21:05:25 +02:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2009-06-19 17:00:26 +02:00
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis role="bold">USER/GROUP</emphasis> (Optional) -
|
|
|
|
[<emphasis
|
|
|
|
role="bold">!</emphasis>][<emphasis>user-name-or-number</emphasis>][<emphasis
|
|
|
|
role="bold">:</emphasis><emphasis>group-name-or-number</emphasis>][<emphasis
|
|
|
|
role="bold">+</emphasis><emphasis>program-name</emphasis>]</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Only locally-generated connections will match if this column
|
|
|
|
is non-empty.</para>
|
|
|
|
|
2009-10-14 00:47:13 +02:00
|
|
|
<para>When this column is non-empty, the rule matches only if the
|
2009-06-19 17:00:26 +02:00
|
|
|
program generating the output is running under the effective
|
|
|
|
<emphasis>user</emphasis> and/or <emphasis>group</emphasis>
|
|
|
|
specified (or is NOT running under that id if "!" is given).</para>
|
|
|
|
|
|
|
|
<para>Examples:</para>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term>joe</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>program must be run by joe</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term>:kids</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>program must be run by a member of the 'kids'
|
|
|
|
group</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term>!:kids</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>program must not be run by a member of the 'kids'
|
|
|
|
group</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term>+upnpd</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>#program named upnpd</para>
|
|
|
|
|
|
|
|
<important>
|
|
|
|
<para>The ability to specify a program name was removed from
|
|
|
|
Netfilter in kernel version 2.6.14.</para>
|
|
|
|
</important>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2012-02-18 17:17:14 +01:00
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis role="bold">SWITCH -
|
2012-11-28 01:17:43 +01:00
|
|
|
[!]<replaceable>switch-name</replaceable>[={0|1}]</emphasis></term>
|
2012-02-18 17:17:14 +01:00
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Added in Shorewall 4.5.1 and allows enabling and disabling the
|
|
|
|
rule without requiring <command>shorewall restart</command>.</para>
|
|
|
|
|
|
|
|
<para>The rule is enabled if the value stored in
|
|
|
|
<filename>/proc/net/nf_condition/<replaceable>switch-name</replaceable></filename>
|
|
|
|
is 1. The rule is disabled if that file contains 0 (the default). If
|
|
|
|
'!' is supplied, the test is inverted such that the rule is enabled
|
2012-11-29 16:17:13 +01:00
|
|
|
if the file contains 0.</para>
|
|
|
|
|
2012-11-29 17:05:49 +01:00
|
|
|
<para>Within the <replaceable>switch-name</replaceable>, '@0' and
|
|
|
|
'@{0}' are replaced by the name of the chain to which the rule is a
|
|
|
|
added. The <replaceable>switch-name</replaceable> (after '@...'
|
|
|
|
expansion) must begin with a letter and be composed of letters,
|
|
|
|
decimal digits, underscores or hyphens. Switch names must be 30
|
|
|
|
characters or less in length.</para>
|
2012-02-18 17:17:14 +01:00
|
|
|
|
|
|
|
<para>Switches are normally <emphasis role="bold">off</emphasis>. To
|
|
|
|
turn a switch <emphasis role="bold">on</emphasis>:</para>
|
|
|
|
|
|
|
|
<simplelist>
|
|
|
|
<member><command>echo 1 >
|
|
|
|
/proc/net/nf_condition/<replaceable>switch-name</replaceable></command></member>
|
|
|
|
</simplelist>
|
|
|
|
|
|
|
|
<para>To turn it <emphasis role="bold">off</emphasis> again:</para>
|
|
|
|
|
|
|
|
<simplelist>
|
|
|
|
<member><command>echo 0 >
|
|
|
|
/proc/net/nf_condition/<replaceable>switch-name</replaceable></command></member>
|
|
|
|
</simplelist>
|
|
|
|
|
|
|
|
<para>Switch settings are retained over <command>shorewall
|
|
|
|
restart</command>.</para>
|
2012-11-28 01:17:43 +01:00
|
|
|
|
2013-05-03 18:19:45 +02:00
|
|
|
<para>Beginning with Shorewall 4.5.10, when the
|
2012-11-28 01:17:43 +01:00
|
|
|
<replaceable>switch-name</replaceable> is followed by
|
|
|
|
<option>=0</option> or <option>=1</option>, then the switch is
|
2012-11-29 17:05:49 +01:00
|
|
|
initialized to off or on respectively by the
|
|
|
|
<command>start</command> command. Other commands do not affect the
|
|
|
|
switch setting.</para>
|
2012-02-18 17:17:14 +01:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2012-06-30 00:32:01 +02:00
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><emphasis role="bold">ORIGINAL DEST</emphasis> (origdest) -
|
|
|
|
[<emphasis
|
|
|
|
role="bold">-</emphasis>|<emphasis>address</emphasis>[,<emphasis>address</emphasis>]...[<emphasis>exclusion</emphasis>]|<emphasis>exclusion</emphasis>]</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>(Optional) Added in Shorewall 4.5.6. 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. It
|
|
|
|
is useful for specifying that SNAT should occur only for connections
|
|
|
|
that were acted on by a DNAT when they entered the firewall.</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2006-11-15 21:04:33 +01:00
|
|
|
</variablelist>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Examples</title>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term>Example 1:</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>You have a simple masquerading setup where eth0 connects to a
|
|
|
|
DSL or cable modem and eth1 connects to your local network with
|
2006-11-20 18:52:52 +01:00
|
|
|
subnet 192.168.0.0/24.</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
2010-09-08 15:04:57 +02:00
|
|
|
<para>Your entry in the file will be:</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<programlisting> #INTERFACE SOURCE
|
|
|
|
eth0 192.168.0.0/24</programlisting>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term>Example 2:</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>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:</para>
|
|
|
|
|
|
|
|
<programlisting> #INTERFACE SOURCE
|
|
|
|
eth0 192.168.1.0/24</programlisting>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term>Example 3:</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>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:</para>
|
|
|
|
|
|
|
|
<programlisting> #INTERFACE SOURCE
|
|
|
|
ipsec0:10.1.1.0/24 196.168.1.0/24</programlisting>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term>Example 4:</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>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
|
2006-11-20 18:52:52 +01:00
|
|
|
address of eth0. You want 206.124.146.176 to be added to eth0 with
|
|
|
|
name eth0:0.</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<programlisting> #INTERFACE SOURCE ADDRESS
|
|
|
|
eth0:0 192.168.1.0/24 206.124.146.176</programlisting>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2011-04-21 01:20:42 +02:00
|
|
|
<term>Example 5:</term>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<listitem>
|
2010-09-08 15:04:57 +02:00
|
|
|
<para>You want all outgoing SMTP traffic entering the firewall from
|
|
|
|
172.20.1.0/29 to be sent from eth0 with source IP address
|
|
|
|
206.124.146.177. You want all other outgoing traffic from
|
|
|
|
172.20.1.0/29 to be sent from eth0 with source IP address
|
|
|
|
206.124.146.176.</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
2010-09-08 15:04:57 +02:00
|
|
|
<programlisting> #INTERFACE SOURCE ADDRESS PROTO PORT(S)
|
|
|
|
eth0 172.20.1.0/29 206.124.146.177 tcp smtp
|
|
|
|
eth0 172.20.1.0/29 206.124.146.176</programlisting>
|
2006-11-15 21:04:33 +01:00
|
|
|
|
|
|
|
<warning>
|
|
|
|
<para>The order of the above two rules is significant!</para>
|
|
|
|
</warning>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2012-02-18 17:17:14 +01:00
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term>Example 6:</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Connections leaving on eth0 and destined to any host defined
|
|
|
|
in the ipset <emphasis>myset</emphasis> should have the source IP
|
|
|
|
address changed to 206.124.146.177.</para>
|
|
|
|
|
|
|
|
<programlisting> #INTERFACE SOURCE ADDRESS
|
|
|
|
eth0:+myset[dst] - 206.124.146.177</programlisting>
|
2012-10-26 16:10:26 +02:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term>Example 7:</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>SNAT outgoing connections on eth0 from 192.168.1.0/24 in
|
|
|
|
round-robin fashion between addresses 1.1.1.1, 1.1.1.3, and 1.1.1.9
|
|
|
|
(Shorewall 4.5.9 and later).</para>
|
|
|
|
|
|
|
|
<programlisting>/etc/shorewall/tcrules:
|
|
|
|
|
|
|
|
#ACTION SOURCE DEST PROTO PORT(S) SOURCE USER TEST
|
|
|
|
# PORT(S)
|
|
|
|
1-3:CF 192.168.1.0/24 eth0 ; state=NEW
|
|
|
|
|
|
|
|
/etc/shorewall/masq:
|
|
|
|
|
|
|
|
#INTERFACE SOURCE ADDRESS ...
|
|
|
|
eth0 192.168.1.0/24 1.1.1.1 ; mark=1:C
|
|
|
|
eth0 192.168.1.0/24 1.1.1.3 ; mark=2:C
|
|
|
|
eth0 192.168.1.0/24 1.1.1.4 ; mark=3:C</programlisting>
|
2013-12-14 00:44:16 +01:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term>Example 8:</term>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>Your eth1 has two public IP addresses: 70.90.191.121 and
|
|
|
|
70.90.191.123. You want to use the iptables statistics match to
|
|
|
|
masquerade outgoing connections evenly between these two
|
|
|
|
addresses.</para>
|
|
|
|
|
|
|
|
<programlisting>/etc/shorewall/masq:
|
|
|
|
|
|
|
|
#INTERFACE SOURCE ADDRESS
|
|
|
|
INLINE(eth1) 0.0.0.0/0 70.90.191.121 ; -m statistic --mode random --probability 0.50
|
|
|
|
eth1 0.0.0.0/0 70.90.191.123
|
|
|
|
</programlisting>
|
2013-12-14 22:35:01 +01:00
|
|
|
|
|
|
|
<para>If INLINE_MATCHES=Yes in <ulink
|
2014-01-16 17:32:57 +01:00
|
|
|
url="/manpages/shorewall.conf.html">shorewall.conf(5)</ulink>, then
|
|
|
|
these rules may be specified as follows:</para>
|
2013-12-14 22:35:01 +01:00
|
|
|
|
|
|
|
<programlisting>/etc/shorewall/masq:
|
|
|
|
|
|
|
|
#INTERFACE SOURCE ADDRESS
|
|
|
|
eth1 0.0.0.0/0 70.90.191.121 ; -m statistic --mode random --probability 0.50
|
|
|
|
eth1 0.0.0.0/0 70.90.191.123
|
|
|
|
</programlisting>
|
2012-02-18 17:17:14 +01:00
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2006-11-15 21:04:33 +01:00
|
|
|
</variablelist>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>FILES</title>
|
|
|
|
|
|
|
|
<para>/etc/shorewall/masq</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>See ALSO</title>
|
|
|
|
|
2011-09-26 19:16:52 +02:00
|
|
|
<para><ulink
|
2014-01-12 22:40:03 +01:00
|
|
|
url="/configuration_file_basics.htm#Pairs">http://www.shorewall.net/configuration_file_basics.htm#Pairs</ulink></para>
|
2011-09-26 19:16:52 +02:00
|
|
|
|
2006-11-15 21:04:33 +01:00
|
|
|
<para>shorewall(8), shorewall-accounting(5), shorewall-actions(5),
|
2006-11-25 19:06:11 +01:00
|
|
|
shorewall-blacklist(5), shorewall-exclusion(5), shorewall-hosts(5),
|
2010-11-21 17:48:12 +01:00
|
|
|
shorewall_interfaces(5), shorewall-ipsets(5), shorewall-maclist(5),
|
|
|
|
shorewall-nat(5), shorewall-netmap(5), shorewall-params(5),
|
|
|
|
shorewall-policy(5), shorewall-providers(5), shorewall-proxyarp(5),
|
2012-01-09 16:19:10 +01:00
|
|
|
shorewall-rtrules(5), shorewall-routestopped(5), shorewall-rules(5),
|
2010-11-21 17:48:12 +01:00
|
|
|
shorewall.conf(5), shorewall-secmarks(5), shorewall-tcclasses(5),
|
2013-12-29 00:35:08 +01:00
|
|
|
shorewall-tcdevices(5), shorewall-mangle(5), shorewall-tos(5),
|
2010-11-21 17:48:12 +01:00
|
|
|
shorewall-tunnels(5), shorewall-zones(5)</para>
|
2006-11-15 21:04:33 +01:00
|
|
|
</refsect1>
|
2008-11-25 20:09:36 +01:00
|
|
|
</refentry>
|