'\" t .\" Title: shorewall-snat .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 09/24/2020 .\" Manual: Configuration Files .\" Source: Configuration Files .\" Language: English .\" .TH "SHOREWALL\-SNAT" "5" "09/24/2020" "Configuration Files" "Configuration Files" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" snat \- Shorewall SNAT/Masquerade definition file .SH "SYNOPSIS" .HP \w'\fB/etc/shorewall[6]/snat\fR\ 'u \fB/etc/shorewall[6]/snat\fR .SH "DESCRIPTION" .PP This file is used to define dynamic NAT (Masquerading) and to define Source NAT (SNAT)\&. It superseded \m[blue]\fBshorewall\-masq\fR\m[]\&\s-2\u[1]\d\s+2(5) in Shorewall 5\&.0\&.14\&. .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBWarning\fR .ps -1 .br .PP The entries in this file are order\-sensitive\&. The first entry that matches a particular connection will be the one that is used\&. .sp .5v .RE .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBWarning\fR .ps -1 .br .PP If you have more than one ISP link, adding entries to this file will \fBnot\fR force connections to go out through a particular link\&. You must use entries in \m[blue]\fBshorewall\-rtrules\fR\m[]\&\s-2\u[2]\d\s+2(5) or PREROUTING entries in \m[blue]\fBshorewall\-mangle\fR\m[]\&\s-2\u[3]\d\s+2(5) to do that\&. .sp .5v .RE .PP Beginning with Shorewall 5\&.2\&.6, the snat file supports two different formats: .sp .RS 4 .ie n \{\ \h'-04' 1.\h'+01'\c .\} .el \{\ .sp -1 .IP " 1." 4.2 .\} The SPORT (source port) column is omitted\&. This is the default unless a "?FORMAT 2" compiler directive is included\&. .RE .sp .RS 4 .ie n \{\ \h'-04' 2.\h'+01'\c .\} .el \{\ .sp -1 .IP " 2." 4.2 .\} The SPORT column immediately follows the DPORT column\&. .RE .PP The columns in the file are as follows\&. .PP \fBACTION\fR .RS 4 Defines the type of rule to generate\&. Beginning with Shorewall 5\&.1\&.9, with the exception of NFLOG and ULOG, the action may be followed by a colon (":") and a \fIlog level\fR (see \m[blue]\fBshorewall\-logging(5)\fR\m[]\&\s-2\u[4]\d\s+2)\&. .sp Choices for ACTION are: .PP \fB\fIaction\fR\fR[+][(\fIparameter\fR,\&.\&.\&.)][:\fIlevel\fR] .RS 4 where \fIaction\fR is an action declared in \m[blue]\fBshorewall\-actions(5)\fR\m[]\&\s-2\u[5]\d\s+2 with the \fBnat\fR option\&. See \m[blue]\fBhttps://shorewall\&.org/Actions\&.html\fR\m[]\&\s-2\u[6]\d\s+2 for further information\&. .RE .PP \fBCONTINUE\fR[+]:\fIlevel\fR .RS 4 Causes matching packets to be exempted from any following rules in the file\&. .RE .PP \fBLOG:\fR\fB\fIlevel\fR\fR .RS 4 Added in Shorewall 5\&.1\&.9\&. Simply log the packet and continue with the next rule\&. .RE .PP \fBMASQUERADE[+]\fR[([\fIlowport\fR[\-\fIhighport\fR]][\fBrandom\fR])][:\fIlevel\fR] .RS 4 Causes matching outgoing packages to have their source IP address set to the primary IP address of the interface specified in the DEST column\&. if \fIlowport\fR\-\fIhighport\fR is given, that port range will be used to assign a source port\&. If only \fIlowport\fR is given, that port will be assigned, if possible\&. If option \fBrandom\fR is used then port mapping will be randomized\&. MASQUERADE should only be used when the DEST interface has a dynamic IP address\&. Otherwise, SNAT should be used and should specify the interface\*(Aqs static address\&. .RE .PP \fBNFLOG\fR[(\fInflog\-parameters\fR)] .RS 4 Added in Shorewall 5\&.1\&.9\&. Queues matching packets to a back end logging daemon via a netlink socket then continues to the next rule\&. See \m[blue]\fBshorewall\-logging(5)\fR\m[]\&\s-2\u[4]\d\s+2\&. .sp The \fInflog\-parameters\fR are a comma\-separated list of up to 3 numbers: .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The first number specifies the netlink group (0\-65535)\&. If omitted (e\&.g\&., NFLOG(,0,10)) then a value of 0 is assumed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The second number specifies the maximum number of bytes to copy\&. If omitted, 0 (no limit) is assumed\&. .RE .sp .RS 4 .ie n \{\ \h'-04'\(bu\h'+03'\c .\} .el \{\ .sp -1 .IP \(bu 2.3 .\} The third number specifies the number of log messages that should be buffered in the kernel before they are sent to user space\&. The default is 1\&. .RE .sp NFLOG is similar to\fB LOG:NFLOG\fR[(\fInflog\-parameters\fR)], except that the log level is not changed when this ACTION is used in an action or macro body and the invocation of that action or macro specifies a log level\&. .RE .PP \fBSNAT[+]\fR([\fIaddress\-or\-address\-range\fR][:\fIlowport\fR\fB[\-\fR\fIhighport\fR]][\fB:random\fR][:\fBpersistent\fR]|\fBdetect\fR)[:\fIlevel\fR] .RS 4 If you specify an address here, matching packets will have their source address set to that address\&. If ADD_SNAT_ALIASES is set to Yes or yes in \m[blue]\fBshorewall\&.conf\fR\m[]\&\s-2\u[7]\d\s+2(5) then Shorewall will automatically add this address to the INTERFACE named in the first column (IPv4 only)\&. .sp 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 \fIfirst\&.ip\&.in\&.range\fR\-\fIlast\&.ip\&.in\&.range\fR\&. You may follow the port range with\fB :random\fR in which case assignment of ports from the list will be random\&. \fBrandom\fR may also be specified by itself in this column in which case random local port assignments are made for the outgoing connections\&. .sp Example: 206\&.124\&.146\&.177\-206\&.124\&.146\&.180 .sp You may follow the port range (or \fB:random\fR) with \fB:persistent\fR\&. This is only useful when an address range is specified and causes a client to be given the same source/destination IP pair\&. .sp You may also use the special value \fBdetect\fR which causes Shorewall to determine the IP addresses configured on the interface named in the DEST column and substitute them in this column\&. .sp DNS Names names are not allowed\&. .sp 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 \fIlowport\fR\-\fIhighport\fR\&. If this is done, you must specify "tcp", "udp", "dccp" or "stcp" in the PROTO column\&. .sp Examples: .sp .if n \{\ .RS 4 .\} .nf 192\&.0\&.2\&.4:5000\-6000 :4000\-5000 .fi .if n \{\ .RE .\} .sp You may also specify a single port number, which will be assigned to the outgoing connection, if possible\&. .RE .PP \fBULOG\fR[(\fIulog\-parameters\fR)] .RS 4 IPv4 only\&. Added in Shorewall 5\&.1\&.9\&. Queues matching packets to a back end logging daemon via a netlink socket then continues to the next rule\&. See \m[blue]\fBshorewall\-logging(5)\fR\m[]\&\s-2\u[4]\d\s+2\&. .sp Similar to\fB LOG:ULOG\fR[(\fIulog\-parameters\fR)], except that the log level is not changed when this ACTION is used in an action or macro body and the invocation of that action or macro specifies a log level\&. .RE .sp Normally Masq/SNAT rules are evaluated after those for one\-to\-one NAT (defined in \m[blue]\fBshorewall\-nat\fR\m[]\&\s-2\u[8]\d\s+2(5))\&. If you want the rule to be applied before one\-to\-one NAT rules, follow the action name with "+": This feature should only be required if you need to insert rules in this file that preempt entries in \m[blue]\fBshorewall\-nat\fR\m[]\&\s-2\u[8]\d\s+2(5)\&. .RE .PP \fBSOURCE\fR (Optional) \- [\fIinterface\fR|\fIaddress\fR[\fB,\fR\fIaddress\fR\&.\&.\&.][\fIexclusion\fR]] .RS 4 Set of hosts that you wish to masquerade\&. You can specify this as an \fIaddress\fR (net or host) or as an \fIinterface\fR\&. Unless you want to perform SNAT in the INPUT chain (see DEST below), if you give the name of an interface (deprecated), 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)\&. .sp 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\&. .RE .PP \fBDEST\fR \- {\fIinterface\fR[\fB:\fR\fIdigit][,\fR\fIinterface\fR[\fB:\fR\fIdigit\fR]]\&.\&.\&.|$FW}[\fB:\fR[\fIdest\-address\fR[\fB,\fR\fIdest\-address\fR]\&.\&.\&.[\fIexclusion\fR]] .RS 4 Outgoing \fIinterface\fRs and destination networks\&. Multiple interfaces may be listed when the ACTION is MASQUERADE, but this is usually just your internet interface\&. If ADD_SNAT_ALIASES=Yes in \m[blue]\fBshorewall\&.conf\fR\m[]\&\s-2\u[7]\d\s+2(5), you may add ":" and a \fIdigit\fR 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\&. \fBThat is the only use for the alias name; it may not appear in any other place in your Shorewall configuration\&.\fR .sp Beginning with Shorewall 5\&.1\&.12, SNAT may be performed in the nat table\*(Aqs INPUT chain by specifying $FW rather than one or more interfaces\&. .sp Each interface must match an entry in \m[blue]\fBshorewall\-interfaces\fR\m[]\&\s-2\u[9]\d\s+2(5)\&. Shorewall allows loose matches to wildcard entries in \m[blue]\fBshorewall\-interfaces\fR\m[]\&\s-2\u[9]\d\s+2(5)\&. For example, ppp0 in this file will match a \m[blue]\fBshorewall\-interfaces\fR\m[]\&\s-2\u[9]\d\s+2(5) entry that defines ppp+\&. .sp Where \m[blue]\fBmore that one internet provider share a single interface\fR\m[]\&\s-2\u[10]\d\s+2, the provider is specified by including the provider name or number in parentheses: .sp .if n \{\ .RS 4 .\} .nf eth0(Avvanta) .fi .if n \{\ .RE .\} .sp In that case, you will want to specify the interface\*(Aqs address for that provider as the SNAT parameter\&. .sp 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 \m[blue]\fBshorewall\-exclusion\fR\m[]\&\s-2\u[11]\d\s+2(5)) as are ipset names preceded by a plus sign \*(Aq+\*(Aq; .sp If you wish to inhibit the action of ADD_SNAT_ALIASES for this entry then include the ":" but omit the digit: .sp .if n \{\ .RS 4 .\} .nf eth0(Avvanta): eth2::192\&.0\&.2\&.32/27 .fi .if n \{\ .RE .\} .sp Comments may be attached to Netfilter rules generated from entries in this file through the use of ?COMMENT lines\&. These lines begin with ?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 containing only ?COMMENT\&. .RE .PP \fBPROTO\fR (Optional) \- {\fB\-\fR|[!]{\fIprotocol\-name\fR|\fIprotocol\-number\fR}[,\&.\&.\&.]|+\fIipset\fR} .RS 4 If you wish to restrict this entry to a particular protocol then enter the protocol name (from protocols(5)) or number here\&. See \m[blue]\fBshorewall\-rules(5)\fR\m[]\&\s-2\u[12]\d\s+2 for details\&. .sp Beginning with Shorewall 4\&.5\&.12, this column can accept a comma\-separated list of protocols\&. .sp Beginning with Shorewall 4\&.6\&.0, an \fIipset\fR name can be specified in this column\&. This is intended to be used with bitmap:port ipsets\&. .RE .PP \fB{PORT|DPORT}\fR (Optional) \- {\-|[!]\fIport\-name\-or\-number\fR[,\fIport\-name\-or\-number\fR]\&.\&.\&.|+\fIipset\fR} .RS 4 The column was renamed to DPORT in Shorewall 5\&.2\&.6\&. Beginning with that release, both PORT and DPORT are accepted in the alternative input format, .sp If the PROTO column specifies TCP (6), UDP (17), DCCP (33), SCTP (132) or UDPLITE (136) then you may list one or more port numbers (or names from services(5)) or port ranges separated by commas\&. .sp Port ranges are of the form \fIlowport\fR:\fIhighport\fR\&. .sp Beginning with Shorewall 4\&.6\&.0, an \fIipset\fR name can be specified in this column\&. This is intended to be used with bitmap:port ipsets\&. .RE .PP \fBSPORT {\-|[!]\fR\fB\fIport\-name\-or\-number\fR\fR\fB[,\fR\fB\fIport\-name\-or\-number\fR\fR\fB]\&.\&.\&.|+\fR\fB\fIipset\fR\fR\fB}\fR .RS 4 FORMAT 2 only\&. .sp If the PROTO column specifies TCP (6), UDP (17), DCCP (33), SCTP (132) or UDPLITE (136) then you may list one or more port numbers (or names from services(5)) or port ranges separated by commas\&. .sp Port ranges are of the form \fIlowport\fR:\fIhighport\fR\&. .sp An \fIipset\fR name can be specified in this column\&. This is intended to be used with bitmap:port ipsets\&. .RE .PP \fBIPSEC\fR (Optional) \- [\fIoption\fR[\fB,\fR\fIoption\fR]\&.\&.\&.] .RS 4 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\&. .sp 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\&. .PP \fBreqid=\fR\fInumber\fR .RS 4 where \fInumber\fR is specified using setkey(8) using the \*(Aqunique:\fInumber\fR option for the SPD level\&. .RE .PP \fBspi=\fR .RS 4 where \fInumber\fR is the SPI of the SA used to encrypt/decrypt packets\&. .RE .PP \fBproto=\fR\fBah\fR|\fBesp\fR|\fBipcomp\fR .RS 4 IPSEC Encapsulation Protocol .RE .PP \fBmss=\fR\fInumber\fR .RS 4 sets the MSS field in TCP packets .RE .PP \fBmode=\fR\fBtransport\fR|\fBtunnel\fR .RS 4 IPSEC mode .RE .PP \fBtunnel\-src=\fR\fIaddress\fR[/\fImask\fR] .RS 4 only available with mode=tunnel .RE .PP \fBtunnel\-dst=\fR\fIaddress\fR[/\fImask\fR] .RS 4 only available with mode=tunnel .RE .PP \fBstrict\fR .RS 4 Means that packets must match all rules\&. .RE .PP \fBnext\fR .RS 4 Separates rules; can only be used with strict .RE .PP \fByes\fR .RS 4 When used by itself, causes all traffic that will be encrypted/encapsulated to match the rule\&. .RE .RE .PP \fBMARK\fR \- [\fB!\fR]\fIvalue\fR[/\fImask\fR][\fB:C\fR] .RS 4 Defines a test on the existing packet or connection mark\&. The rule will match only if the test returns true\&. .sp If you don\*(Aqt want to define a test but need to specify anything in the following columns, place a "\-" in this field\&. .PP ! .RS 4 Inverts the test (not equal) .RE .PP \fIvalue\fR .RS 4 Value of the packet or connection mark\&. .RE .PP \fImask\fR .RS 4 A mask to be applied to the mark before testing\&. .RE .PP \fB:C\fR .RS 4 Designates a connection mark\&. If omitted, the packet mark\*(Aqs value is tested\&. .RE .RE .PP \fBUSER\fR (Optional) \- [\fB!\fR][\fIuser\-name\-or\-number\fR][\fB:\fR\fIgroup\-name\-or\-number\fR][\fB+\fR\fIprogram\-name\fR] .RS 4 This column was formerly labelled USER/GROUP\&. .sp Only locally\-generated connections will match if this column is non\-empty\&. .sp When this column is non\-empty, the rule matches only if the program generating the output is running under the effective \fIuser\fR and/or \fIgroup\fR specified (or is NOT running under that id if "!" is given)\&. .sp Examples: .PP joe .RS 4 program must be run by joe .RE .PP :kids .RS 4 program must be run by a member of the \*(Aqkids\*(Aq group .RE .PP !:kids .RS 4 program must not be run by a member of the \*(Aqkids\*(Aq group .RE .PP +upnpd .RS 4 #program named upnpd .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBImportant\fR .ps -1 .br The ability to specify a program name was removed from Netfilter in kernel version 2\&.6\&.14\&. .sp .5v .RE .RE .RE .PP \fBSWITCH \- [!]\fR\fB\fIswitch\-name\fR\fR\fB[={0|1}]\fR .RS 4 Added in Shorewall 4\&.5\&.1 and allows enabling and disabling the rule without requiring \fBshorewall restart\fR\&. .sp The rule is enabled if the value stored in /proc/net/nf_condition/\fIswitch\-name\fR is 1\&. The rule is disabled if that file contains 0 (the default)\&. If \*(Aq!\*(Aq is supplied, the test is inverted such that the rule is enabled if the file contains 0\&. .sp Within the \fIswitch\-name\fR, \*(Aq@0\*(Aq and \*(Aq@{0}\*(Aq are replaced by the name of the chain to which the rule is a added\&. The \fIswitch\-name\fR (after \*(Aq@\&.\&.\&.\*(Aq 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\&. .sp Switches are normally \fBoff\fR\&. To turn a switch \fBon\fR: .RS 4 \fBecho 1 > /proc/net/nf_condition/\fR\fB\fIswitch\-name\fR\fR .RE To turn it \fBoff\fR again: .RS 4 \fBecho 0 > /proc/net/nf_condition/\fR\fB\fIswitch\-name\fR\fR .RE Switch settings are retained over \fBshorewall restart\fR\&. .sp Beginning with Shorewall 4\&.5\&.10, when the \fIswitch\-name\fR is followed by \fB=0\fR or \fB=1\fR, then the switch is initialized to off or on respectively by the \fBstart\fR command\&. Other commands do not affect the switch setting\&. .RE .PP \fBORIGDEST\fR \- [\fB\-\fR|\fIaddress\fR[,\fIaddress\fR]\&.\&.\&.[\fIexclusion\fR]|\fIexclusion\fR] .RS 4 (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\&. .sp This column was formerly labelled ORIGINAL DEST\&. .RE .PP \fBPROBABILITY\fR \- [\fIprobability\fR] .RS 4 Added in Shorewall 5\&.0\&.0\&. When non\-empty, requires the Statistics Match capability in your kernel and ip6tables and causes the rule to match randomly but with the given \fIprobability\fR\&. The \fIprobability\fR is a number 0 < \fIprobability\fR <= 1 and may be expressed at up to 8 decimal points of precision\&. .RE .SH "EXAMPLES" .PP IPv4 Example 1: .RS 4 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\&. .sp Your entry in the file will be: .sp .if n \{\ .RS 4 .\} .nf #ACTION SOURCE DEST MASQUERADE 192\&.168\&.0\&.0/24 eth0 .fi .if n \{\ .RE .\} .RE .PP IPv4 Example 2: .RS 4 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: .sp .if n \{\ .RS 4 .\} .nf #ACTION SOURCE DEST MASQUERADE 192\&.168\&.0\&.0/24 eth0 MASQUERADE 192\&.168\&.1\&.0/24 eth0 .fi .if n \{\ .RE .\} .RE .PP IPv4 Example 3: .RS 4 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\&. .sp .if n \{\ .RS 4 .\} .nf #ACTION SOURCE DEST SNAT(206\&.124\&.146\&.176) 192\&.168\&.1\&.0/24 eth0:0 .fi .if n \{\ .RE .\} .RE .PP IPv4 Example 4: .RS 4 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\&. .sp .if n \{\ .RS 4 .\} .nf #INTERFACE SOURCE ADDRESS PROTO DPORT eth0 172\&.20\&.1\&.0/29 206\&.124\&.146\&.177 tcp smtp eth0 172\&.20\&.1\&.0/29 206\&.124\&.146\&.176 .fi .if n \{\ .RE .\} .sp .if n \{\ .RS 4 .\} .nf #ACTION SOURCE DEST PROTO PORT SNAT(206\&.124\&.146\&.177) 172\&.20\&.1\&.0/29 eth0 tcp smtp SNAT(206\&.124\&.146\&.176) 172\&.20\&.1\&.0/29 eth0 .fi .if n \{\ .RE .\} .if n \{\ .sp .\} .RS 4 .it 1 an-trap .nr an-no-space-flag 1 .nr an-break-flag 1 .br .ps +1 \fBWarning\fR .ps -1 .br The order of the above two rules is significant! .sp .5v .RE .RE .PP IPv4 Example 5: .RS 4 Connections leaving on eth0 and destined to any host defined in the ipset \fImyset\fR should have the source IP address changed to 206\&.124\&.146\&.177\&. .sp .if n \{\ .RS 4 .\} .nf #ACTION SOURCE DEST SNAT(206\&.124\&.146\&.177) \- eth0:+myset[dst] .fi .if n \{\ .RE .\} .RE .PP IPv4 Example 6: .RS 4 SNAT outgoing connections on eth0 from 192\&.168\&.1\&.0/24 randomly to addresses 1\&.1\&.1\&.1, 1\&.1\&.1\&.3, and 1\&.1\&.1\&.9 (Shorewall 5\&.0\&.0 and later)\&. .sp .if n \{\ .RS 4 .\} .nf /etc/shorewall/snat: #ACTION SOURCE DEST SNAT(1\&.1\&.1\&.1) 192\&.168\&.1\&.0/24 eth0 { probability=0\&.33 } SNAT(1\&.1\&.1\&.3) 192\&.168\&.1\&.0/24 eth0 { probability=0\&.50 } SNAT(1\&.1\&.1\&.9) 192\&.168\&.1\&.0/24 eth0 .fi .if n \{\ .RE .\} .RE .PP IPv6 Example 1: .RS 4 You have a simple \*(Aqmasquerading\*(Aq setup where eth0 connects to a DSL or cable modem and eth1 connects to your local network with subnet 2001:470:b:787::0/64 .sp Your entry in the file will be: .sp .if n \{\ .RS 4 .\} .nf #ACTION SOURCE DEST MASQUERADE 2001:470:b:787::0/64 eth0 .fi .if n \{\ .RE .\} .RE .PP IPv6 Example 2: .RS 4 Your sit1 interface has two public IP addresses: 2001:470:a:227::1 and 2001:470:b:227::1\&. You want to use the iptables statistics match to masquerade outgoing connections evenly between these two addresses\&. .sp .if n \{\ .RS 4 .\} .nf /etc/shorewall/snat: #ACTION SOURCE DEST SNAT(2001:470:a:227::1) ::/0 sit1 { probability=0\&.50 } SNAT(2001:470:a:227::2) ::/0 sit .fi .if n \{\ .RE .\} .RE .SH "FILES" .PP /etc/shorewall/snat .PP /etc/shorewall6/snat .SH "SEE ALSO" .PP \m[blue]\fBhttps://shorewall\&.org/configuration_file_basics\&.htm#Pairs\fR\m[]\&\s-2\u[13]\d\s+2 .PP shorewall(8) .SH "NOTES" .IP " 1." 4 shorewall-masq .RS 4 \%https://shorewall.org/manpages/shorewall-masq.html .RE .IP " 2." 4 shorewall-rtrules .RS 4 \%https://shorewall.org/manpages/shorewall-rtrules.html .RE .IP " 3." 4 shorewall-mangle .RS 4 \%https://shorewall.org/manpages/shorewall-mangle.html .RE .IP " 4." 4 shorewall-logging(5) .RS 4 \%https://shorewall.org/manpages/shorewall-logging.html .RE .IP " 5." 4 shorewall-actions(5) .RS 4 \%https://shorewall.org/manpages/shorewall-actions.html .RE .IP " 6." 4 https://shorewall.org/Actions.html .RS 4 \%https://shorewall.org/Actions.html .RE .IP " 7." 4 shorewall.conf .RS 4 \%https://shorewall.org/manpages/shorewall.conf.html .RE .IP " 8." 4 shorewall-nat .RS 4 \%https://shorewall.org/manpages/shorewall-nat.html .RE .IP " 9." 4 shorewall-interfaces .RS 4 \%https://shorewall.org/manpages/shorewall-interfaces.html .RE .IP "10." 4 more that one internet provider share a single interface .RS 4 \%https://shorewall.org/4.4/MultiISP.html#Shared .RE .IP "11." 4 shorewall-exclusion .RS 4 \%https://shorewall.org/manpages/shorewall-exclusion.html .RE .IP "12." 4 shorewall-rules(5) .RS 4 \%https://shorewall.org/manpages/shorewall-rules.html .RE .IP "13." 4 https://shorewall.org/configuration_file_basics.htm#Pairs .RS 4 \%https://shorewall.org/configuration_file_basics.htm#Pairs .RE