shorewall-files5Configuration FilesfilesShorewall Configuration Files/etc/shorewall[6]/*DescriptionThe following are the Shorewall[6] configuration files:/etc/shorewall/shorewall.conf
and /etc/shorewall6/shorewall6.conf -
used to set global firewall parameters./etc/shorewall[6]/params
- use this file to set shell variables that you will expand in other
files. It is always processed by /bin/sh or by the shell specified
through SHOREWALL_SHELL in
/etc/shorewall/shorewall.conf./etc/shorewall[6]/zones
- partition the firewall's view of the world into zones./etc/shorewall[6]/policy
- establishes firewall high-level policy./etc/shorewall[6]/initdone - An optional
Perl script that will be invoked by the Shorewall rules compiler when
the compiler has finished it's initialization./etc/shorewall[6]/interfaces
- describes the interfaces on the firewall system./etc/shorewall[6]/hosts
- allows defining zones in terms of individual hosts and
subnetworks./etc/shorewall[6]/masq -
directs the firewall where to use many-to-one (dynamic) Network
Address Translation (a.k.a. Masquerading) and Source Network Address
Translation (SNAT). Superseded by /etc/shorewall[6]/snat in Shorewall
5.0.14 and not supported in Shorewall 5.1.0 and later versions./etc/shorewall[6]/mangle
- supersedes /etc/shorewall/tcrules in Shorewall
4.6.0. Contains rules for packet marking, TTL, TPROXY, etc./etc/shorewall[6]/rules
- defines rules that are exceptions to the overall policies
established in /etc/shorewall/policy./etc/shorewall[6]/nat -
defines one-to-one NAT rules./etc/shorewall6/proxyarp
- defines use of Proxy ARP./etc/shorewall6/proxyndp
- defines use of Proxy NDP./etc/shorewall[6]/routestopped - defines
hosts accessible when Shorewall is stopped. Superseded in Shorewall
4.6.8 by /etc/shorewall/stoppedrules. Not
supported in Shorewall 5.0.0 and later versions./etc/shorewall[6]/tcrules- The file has a rather unfortunate name because it is used
to define marking of packets for later use by both traffic
control/shaping and policy routing. This file is superseded by
/etc/shorewall/mangle in Shorewall 4.6.0. Not
supported in Shorewall 5.0.0 and later releases./etc/shorewall[6]/tos -
defines rules for setting the TOS field in packet headers. Superseded
in Shorewall 4.5.1 by the TOS target in
/etc/shorewall/tcrules (which file has since been
superseded by /etc/shorewall/mangle). Not
supported in Shorewall 5.0.0 and later versions./etc/shorewall[6]/tunnels
- defines tunnels (VPN) with end-points on the firewall system./etc/shorewall[6]/blacklist
- Deprecated in favor of /etc/shorewall/blrules.
Lists blacklisted IP/subnet/MAC addresses. Not supported in Shorewall
5.0.0 and later releases./etc/shorewall[6]/blrules — Added in
Shorewall 4.5.0. Define blacklisting and whitelisting. Supersedes
/etc/shorewall/blacklist./etc/shorewall[6]/init - shell commands
that you wish to execute at the beginning of a shorewall
start, "shorewall reload" or shorewall
restart./etc/shorewall[6]/start - shell commands
that you wish to execute near the completion of a shorewall
start, "shorewall reload" or shorewall
restart/etc/shorewall[6]/started - shell commands
that you wish to execute after the completion of a shorewall
start, "shorewall reload" or shorewall
restart/etc/shorewall[6]/stop - commands that you
wish to execute at the beginning of a shorewall
stop./etc/shorewall[6]/stopped - shell commands
that you wish to execute at the completion of a shorewall
stop./etc/shorewall/ecn -
disable Explicit Congestion Notification (ECN - RFC 3168) to remote
hosts or networks. Superseded by ECN entries in
/etc/shorewall/mangle in Shorewall 5.0.6./etc/shorewall/accounting
- define IP traffic accounting rules/etc/shorewall[6]/actions
and /usr/share/shorewall[6]/action.template allow
user-defined actions./etc/shorewall[6]/providers - defines
alternate routing tables./etc/shorewall[6]/rtrules
- Defines routing rules to be used in conjunction with the routing
tables defined in
/etc/shorewall/providers./etc/shorewall[6]/tcdevices,
/etc/shorewall[6]/tcclasses,
/etc/shorewall[6]/tcfilters
- Define complex traffic shaping./etc/shorewall[6]/tcrules
- Mark or classify traffic for traffic shaping or multiple providers.
Deprecated in Shorewall 4.6.0 in favor of
/etc/shorewall/mangle. Not supported in Shorewall
5.0.0 and later releases./etc/shorewall[6]/tcinterfaces
and /etc/shorewall[6]/tcpri
- Define simple traffic shaping./etc/shorewall[6]/secmarks
- Added in Shorewall 4.4.13. Attach an SELinux context to selected
packets./etc/shorewall[6]/vardir
- Determines the directory where Shorewall maintains its state./etc/shorewall/arprules
— Added in Shorewall 4.5.12. Allows specification of arptables
rules./etc/shorewall/mangle
-- Added in Shorewall 4.6.0. Supersedes
/etc/shorewall/tcrules./etc/shorewall[6]/snat -
directs the firewall where to use many-to-one (dynamic) Network
Address Translation (a.k.a. Masquerading) and Source Network Address
Translation (SNAT). Superseded /etc/shorewall[6]/masq in Shorewall
5.0.14/usr/share/shorewall[6]/actions.std -
Actions defined by Shorewall./usr/share/shorewall[6]/action.* - Details
of actions defined by Shorewall./usr/share/shorewall[6]/macro.* - Details
of macros defined by Shorewall./usr/share/shorewall[6]/modules — Specifies
the kernel modules to be loaded during shorewall start/restart./usr/share/shorewall[6]/helpers — Added in
Shorewall 4.4.7. Specifies the kernel modules to be loaded during
shorewall start/restart when LOAD_HELPERS_ONLY=Yes in
shorewall.conf.CONFIG_PATHThe CONFIG_PATH option in shorewall[6].conf(5) determines where the compiler
searches for configuration files. The default setting is
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall which means that the
compiler first looks in /etc/shorewall and if it doesn't find the file, it
then looks in /usr/share/shorewall.You can change this setting to have the compiler look in different
places. For example, if you want to put your own versions of standard
macros in /etc/shorewall/Macros, then you could set
CONFIG_PATH=/etc/shorewall:/etc/shorewall/Macros:/usr/share/shorewall and
the compiler will use your versions rather than the standard ones.CommentsYou may place comments in configuration files by making the first
non-whitespace character a pound sign (#). You may also
place comments at the end of any line, again by delimiting the comment
from the rest of the line with a pound sign.Comments in a Configuration File# This is a comment
ACCEPT net $FW tcp www #This is an end-of-line commentExcept in shorewall.conf(5) and params(5), if a comment ends with a
backslash ("\"), the next line will also be treated as a comment. See
Line Continuation below.Blank LinesMost of the configuration files are organized into space-separated
columns. If you don't want to supply a value in a column but want to
supply a value in a following column, simply enter '-' to make the column
appear empty.Example:#INTERFACE BROADCAST OPTIONS
br0 - routebackLine ContinuationLines may be continued using the usual backslash (\)
followed immediately by a new line character (Enter key).ACCEPT net $FW tcp \↵
smtp,www,pop3,imap #Services running on the firewallWhat follows does NOT apply to shorewall-params(5) and
shorewall.conf(5).In certain cases, leading white space is ignored in continuation
lines:The continued line ends with a colon (":")The continued line ends with a comma (",")Example (/etc/shorewall/rules):#ACTION SOURCE DEST PROTO DPORT
ACCEPT net:\
206.124.146.177,\
206.124.146.178,\
206.124.146.180\
dmz tcp 873The leading white space on the first through third continuation
lines is ignored so the SOURCE column effectively contains
"net:206.124.146.177,206.124.147.178,206.124.146.180". Because the third
continuation line does not end with a comma or colon, the leading white
space in the last line is not ignored.A trailing backslash is not ignored in a comment. So the continued
rule above can be commented out with a single '#' as follows:#ACTION SOURCE DEST PROTO DPORT
#ACCEPT net:\
206.124.146.177,\
206.124.146.178,\
206.124.146.180\
dmz tcp 873Alternative Specification of Column ValuesSome of the configuration files now have a large number of columns.
That makes it awkward to specify a value for one of the right-most columns
as you must have the correct number of intervening '-' columns.This problem is addressed by allowing column values to be specified
as column-name/value
pairs.There is considerable flexibility in how you specify the
pairs:At any point, you can enter a left curly bracket ('{') followed
by one or more specifications of the following forms:column-name=valuecolumn-name=>valuecolumn-name:valueThe pairs must be followed by a right curly bracket
("}").The value may optionally be enclosed in double quotes.The pairs must be separated by white space, but you can add a
comma adjacent to the values for
readability as in:{ proto=>udp, port=1024
}You can also separate the pairs from columns by using a
semicolon:; proto:udp,
port:1024In Shorewall 5.0.3, the sample configuration files and the man pages
were updated to use the same column names in both the column headings and
in the alternate specification format. The following table shows the
column names for each of the table-oriented configuration files.Column names are case-insensitive.FileColumn namesaccountingaction,chain, source, dest, proto, dport, sport, user,
mark, ipsec, headersconntrackaction,source,dest,proto,dport,sport,user,switchblacklistnetworks,proto,port,optionsblrulesaction,source,dest,proto,dport,sport,origdest,rate,user,mark,connlimit,time,headers,switch,helperecninterface,hosts. Beginning with Shorewall 4.5.4, 'host' is
a synonym for 'hosts'.hostszone,hosts,options. Beginning with Shorewall 4.5.4, 'host'
is a synonym for 'hosts'.interfaceszone,interface,broadcast,optionsmaclistdisposition,interface,mac,addressesmangleaction,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headersmasqinterface,source,address,proto,port,ipsec,mark,user,switchnatexternal,interface,internal,allints,localnetmaptype,net1,interface,net2,net3,proto,dport,sportnotracksource,dest,proto,dport,sport,userpolicysource,dest,policy,loglevel,limit,connlimitproviderstable,number,mark,duplicate,interface,gateway,options,copyproxyarp and proxyndpaddress,interface,external,haveroute,persistentrtrulessource,dest,provider,priorityroutesprovider,dest,gateway,deviceroutestoppedinterface,hosts,options,proto,dport,sportrulesaction,source,dest,proto,dport,sport,origdest,rate,user,mark,connlimit,time,headers,switch,helpersecmarkssecmark,chain,source,dest,proto,dport,sport,user,marktcclassesinterface,mark,rate,ceil,prio,optionstcdevicesinterface,in_bandwidth,out_bandwidth,options,redirecttcfiltersclass,source,dest,proto,dport,sport,tos,lengthtcinterfacesinterface,type,in_bandwidth,out_bandwidthtcpriband,proto,port,address,interface,helpertcrulesmark,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headers.
Beginning with Shorewall 4.5.3, 'action' is a synonym for
'mark'.tossource,dest,proto,dport,sport,tos,marktunnelstype,zone,gateway,gateway_zone. Beginning with Shorewall
4.5.3, 'gateways' is a synonym for 'gateway'. Beginning with
Shorewall 4.5.4, 'gateway_zones' is a synonym for
'gateway_zone'.zoneszone,type,options,in_options,out_optionsExample (rules file):#ACTION SOURCE DEST PROTO DPORT
DNAT net loc:10.0.0.1 tcp 80 ; mark="88"Here's the same line in several equivalent formats:{ action=>DNAT, source=>net, dest=>loc:10.0.0.1, proto=>tcp, dport=>80, mark=>88 }
; action:"DNAT" source:"net" dest:"loc:10.0.0.1" proto:"tcp" dport:"80" mark:"88"
DNAT { source=net dest=loc:10.0.0.1 proto=tcp dport=80 mark=88 }Beginning with Shorewall 5.0.11, ip[6]table comments can be attached
to individual rules using the keyword.Example from the rules file: ACCEPT net $FW { proto=tcp, dport=22, comment="Accept \"SSH\"" }As shown in that example, when the comment contains whitespace, it
must be enclosed in double quotes and any embedded double quotes must be
escaped using a backslash ("\").Time ColumnsSeveral of the files include a TIME column that allows you to specify
times when the rule is to be applied. Contents of this column is a list of
timeelements separated by apersands
(&).Each timeelement is one of the
following:timestart=hh:mm[:ss]Defines the starting time of day.timestop=hh:mm[:ss]Defines the ending time of day.contiguousAdded in Shoreawll 5.0.12. When timestop is smaller than timestart value, match this as a single time
period instead of distinct intervals. See the Examples below.utcTimes are expressed in Greenwich Mean Time.localtzDeprecated by the Netfilter team in favor of kerneltz. Times are expressed in Local Civil
Time (default).kerneltzAdded in Shorewall 4.5.2. Times are expressed in Local Kernel
Time (requires iptables 1.4.12 or later).weekdays=ddd[,ddd]...where ddd is one of
, , ,
, , or
monthdays=dd[,dd],...where dd is an ordinal day of the
monthdatestart=yyyy[-mm[-dd[hh[:mm[:ss]]]]]Defines the starting date and time.datestop=yyyy[-mm[-dd[hh[:mm[:ss]]]]]Defines the ending date and time.Examples:To match on weekends, use:weekdays=Sat,SunOr, to match (once) on a national holiday block:datestart=2016-12-24&datestop=2016-12-27Since the stop time is actually inclusive, you would need the
following stop time to not match the first second of the new
day:datestart=2016-12-24T17:00&datestop=2016-12-27T23:59:59During Lunch HourThe fourth Friday in the month:weekdays=Fri&monthdays=22,23,24,25,26,27,28Matching across days might not do what is expected. For
instance,weekdays=Mon×tart=23:00×top=01:00Will match Monday, for one hour from midnight to 1 a.m., and
then again for another hour from 23:00 onwards. If this is unwanted,
e.g. if you would like 'match for two hours from Montay 23:00
onwards' you need to also specify the contiguous option in the example
above.Switcheshere are times when you would like to enable or disable one or more
rules in the configuration without having to do a shorewall
reload or shorewall restart. This may be
accomplished using the SWITCH column in shorewall-rules (5) or shorewall6-rules (5). Using
this column requires that your kernel and iptables include
Condition Match Support and you must be running
Shorewall 4.4.24 or later. See the output of shorewall show
capabilities and shorewall version to
determine if you can use this feature.The SWITCH column contains the name of a
switch. Each switch is initially in the off position. You can turn on the switch named
switch1 by:echo 1 >
/proc/net/nf_condition/switch1You can turn it off again by:echo 0 >
/proc/net/nf_condition/switch1If you simply include the switch name in the SWITCH column, then the
rule is enabled only when the switch is on. If you precede the switch name with ! (e.g.,
!switch1), then the rule is enabled only when the switch is off. Switch settings are retained over
shorewall restart.Shorewall requires that switch names:begin with a letter and be composed of letters, digits,
underscore ('_') or hyphen ('-'); andbe 30 characters or less in length.Multiple rules can be controlled by the same switch.Example:
Forward port 80 to dmz host $BACKUP if switch 'primary_down' is
on.#ACTION SOURCE DEST PROTO DPORT SPORT ORIGDEST RATE USER MARK CONNLIMIT TIME HEADERS SWITCH
DNAT net dmz:$BACKUP tcp 80 - - - - - - - - primary_down