The entries in this file are order-sensitive. The first entry that matches a particular connection will be the one that is used.
If you have more than one ISP link, adding entries to this file will not force connections to go out through a particular link. You must use entries in m[blue]shorewall-route_rulesm[][1](5) or PREROUTING entries in m[blue]shorewall-tcrulesm[][2](5) to do that.
The columns in the file are as follows.
INTERFACE:DEST - {[+]interfacelist[:[digit]][:[dest-address[,dest-address]...[exclusion]]|COMMENT}
Each interface must match an entry in m[blue]shorewall-interfacesm[][4](5). Shorewall allows loose matches to wildcard entries in m[blue]shorewall-interfacesm[][4](5). For example, ppp0 in this file will match a m[blue]shorewall-interfacesm[][4](5) entry that defines ppp+.
Where m[blue]more that one internet provider share a single interfacem[][5], the provider is specified by including the provider name or number in parentheses:
eth0(Avvanta)
In that case, you will want to specify the interfaces's address for that provider in the ADDRESS column.
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]shorewall-exclusionm[][6](5)).
If you wish to inhibit the action of ADD_SNAT_ALIASES for this entry then include the ":" but omit the digit:
eth0(Avvanta):
eth2::192.0.2.32/27
Normally Masq/SNAT rules are evaluated after those for one-to-one NAT (defined in m[blue]shorewall-natm[][7](5)). If you want the rule to be applied before one-to-one NAT rules, prefix the interface name with "+":
+eth0
+eth0:192.0.2.32/27
+eth0:2
This feature should only be required if you need to insert rules in this file that preempt entries in m[blue]shorewall-natm[][7](5).
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.
SOURCE (Formerly called SUBNET) - {interface[:exclusion]|address[,address][exclusion]}
In order to exclude a address of the specified SOURCE, you may append an exclusion ("!" and a comma-separated list of IP addresses (host or net) that you wish to exclude (see m[blue]shorewall-exclusionm[][6](5))). Note that a colon (":") must appear between an interface name and the exclusion;
Example: eth1:!192.168.1.4,192.168.32.0/27
In that example traffic from eth1 would be masqueraded unless it came from 192.168.1.4 or 196.168.32.0/27
ADDRESS (Optional) - [-|NONAT|[address-or-address-range[,address-or-address-range]...][:lowport-highport][:random][:persistent]|detect|random]
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 first.ip.in.range-last.ip.in.range. You may follow the port range with :random in which case assignment of ports from the list will be random. random may also be specified by itself in this column in which case random local port assignments are made for the outgoing connections.
Example: 206.124.146.177-206.124.146.180
You may follow the port range (or :random) with :persistent. 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 random, persistent may not be used by itself.
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.
Finally, you may also specify a comma-separated list of ranges and/or addresses in this column.
This column may not contain DNS Names.
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 lowport-highport. If this is done, you must specify "tcp" or "udp" in the PROTO column.
Examples:
192.0.2.4:5000-6000
:4000-5000
If you simply place NONAT in this column, no rewriting of the source IP address or port number will be performed. This is useful if you want particular traffic to be exempt from the entries that follow in the file.
If you want to leave this column empty but you need to specify the next column then place a hyphen ("-") here.
PROTO (Optional) - {-|[!]protocol-name|[!]protocol-number}
PORT(S) (Optional) - [[!]port-name-or-number[,port-name-or-number]...]
Port ranges are of the form lowport:highport.
IPSEC (Optional) - [option[,option]...]
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.
reqid=number
spi=<number>
proto=ah|esp|ipcomp
mss=number
mode=transport|tunnel
tunnel-src=address[/mask]
tunnel-dst=address[/mask]
strict
next
yes
MARK - [!]value[/mask][:C]
If you don't want to define a test but need to specify anything in the following columns, place a "-" in this field.
!
value
mask
:C
USER/GROUP (Optional) - [!][user-name-or-number][:group-name-or-number][+program-name]
When this column is non-empty, the rule matches only if the program generating the output is running under the effective user and/or group specified (or is NOT running under that id if "!" is given).
Examples:
joe
:kids
!:kids
+upnpd
Example 1:
Your entry in the file will be:
#INTERFACE SOURCE
eth0 192.168.0.0/24
Example 2:
#INTERFACE SOURCE
eth0 192.168.1.0/24
Example 3:
#INTERFACE SOURCE
ipsec0:10.1.1.0/24 196.168.1.0/24
Example 4:
#INTERFACE SOURCE ADDRESS
eth0:0 192.168.1.0/24 206.124.146.176
Example 5 (using the deprecated form with an interface name in the SOURCE column):
#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
shorewall(8), shorewall-accounting(5), shorewall-actions(5), shorewall-blacklist(5), shorewall-exclusion(5), shorewall-hosts(5), 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), shorewall-route_rules(5), shorewall-routestopped(5), shorewall-rules(5), shorewall.conf(5), shorewall-secmarks(5), shorewall-tcclasses(5), shorewall-tcdevices(5), shorewall-tcrules(5), shorewall-tos(5), shorewall-tunnels(5), shorewall-zones(5)