SHOREWALL-FILES(5)
πΈ NAME πΈ
files β Shorewall Configuration Files. Bestie, this is the SHOREWALL-FILES(5) page, and it's literally the master roster of every single config file Shorewall and Shorewall6 will read. Keep it bookmarked, iykyk. π
β¨ SYNOPSIS β¨
/etc/shorewall[6]/*
π DESCRIPTION π
okay so, here's the whole cast of Shorewall[6] configuration files, one by one, no skipping, we're doing all of them:
/etc/shorewall/shorewall.confand/etc/shorewall6/shorewall6.conf[1] β the global settings file. all your firewall-wide parameters live here./etc/shorewall[6]/params[2] β use this one to set shell variables that you'll expand in other files. it's always processed by/bin/sh, or by whatever shell you point at withSHOREWALL_SHELLin/etc/shorewall/shorewall.conf./etc/shorewall[6]/zones[3] β this is how you partition the firewall's whole view of the world into zones. main character energy for real./etc/shorewall[6]/policy[4] β establishes the firewall's high-level policy. the big-picture vibe./etc/shorewall[6]/initdoneβ an optional Perl script that gets invoked by the Shorewall rules compiler once the compiler has finished its initialization./etc/shorewall[6]/interfaces[5] β describes the interfaces on the firewall system./etc/shorewall[6]/hosts[6] β lets you define zones in terms of individual hosts and subnetworks./etc/shorewall[6]/masq[7] β tells 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]/snatin Shorewall 5.0.14, and not supported in Shorewall 5.1.0 and later versions./etc/shorewall[6]/mangle[8] β supersedes/etc/shorewall/tcrulesas of Shorewall 4.6.0. holds rules for packet marking, TTL, TPROXY, etc./etc/shorewall[6]/rules[9] β defines the rules that are exceptions to the overall policies you set up in/etc/shorewall/policy./etc/shorewall[6]/nat[10] β defines one-to-one NAT rules./etc/shorewall6/proxyarp[11] β defines use of Proxy ARP./etc/shorewall6/proxyndp[12] β 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[13] β okay so this file has a rather unfortunate name, because it's actually used to define marking of packets for later use by both traffic control/shaping and policy routing. superseded by/etc/shorewall/manglein Shorewall 4.6.0. not supported in Shorewall 5.0.0 and later releases./etc/shorewall[6]/tos[14] β 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[15] β defines tunnels (VPN) with end-points on the firewall system./etc/shorewall[6]/blacklist[16] β 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 you want executed at the beginning of a βshorewall startβ,"shorewall reload"or βshorewall restartβ./etc/shorewall[6]/startβ shell commands you want executed near the completion of a βshorewall startβ,"shorewall reload"or βshorewall restartβ/etc/shorewall[6]/startedβ shell commands you want executed after the completion of a βshorewall startβ,"shorewall reload"or βshorewall restartβ/etc/shorewall[6]/stopβ commands you want executed at the beginning of a βshorewall stopβ./etc/shorewall[6]/stoppedβ shell commands you want executed at the completion of a βshorewall stopβ./etc/shorewall/ecn[17] β disable Explicit Congestion Notification (ECN - RFC 3168) to remote hosts or networks. superseded by ECN entries in/etc/shorewall/manglein Shorewall 5.0.6./etc/shorewall/accounting[18] β define IP traffic accounting rules/etc/shorewall[6]/actions[19] and/usr/share/shorewall[6]/action.templateβ allow user-defined actions. π/etc/shorewall[6]/providers[20] β defines alternate routing tables./etc/shorewall[6]/rtrules[21] β defines routing rules to be used in conjunction with the routing tables defined in/etc/shorewall/providers./etc/shorewall[6]/tcdevices[22],/etc/shorewall[6]/tcclasses[23],/etc/shorewall[6]/tcfilters[24] β define complex traffic shaping./etc/shorewall[6]/tcrules[13] β 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[25] and/etc/shorewall[6]/tcpri[26] β define simple traffic shaping./etc/shorewall[6]/secmarks[27] β added in Shorewall 4.4.13. attach an SELinux context to selected packets./etc/shorewall[6]/vardir[28] β determines the directory where Shorewall maintains its state./etc/shorewall/arprules[29] β added in Shorewall 4.5.12. allows specification of arptables rules./etc/shorewall/mangle[8] β added in Shorewall 4.6.0. supersedes/etc/shorewall/tcrules./etc/shorewall[6]/snat[30] β 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]/masqin 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 whenLOAD_HELPERS_ONLY=Yesinshorewall.conf.
π§ CONFIG_PATH π§
the CONFIG_PATH option in shorewall[6].conf(5)[20] decides where the compiler goes looking for configuration files. the default setting is:
CONFIG_PATH=/etc/shorewall:/usr/share/shorewall
which means the compiler peeks in /etc/shorewall first, and if the file isn't there, it goes looking in /usr/share/shorewall. π«
you can totally change that setting so the compiler hunts in different places. for example, if you want to put your own versions of the standard macros in /etc/shorewall/Macros, you could set:
CONFIG_PATH=/etc/shorewall:/etc/shorewall/Macros:/usr/share/shorewall
and then the compiler will use your versions instead of the standard ones. iconic, honestly.
π¬ COMMENTS π¬
you can drop comments into configuration files by making the first non-whitespace character a pound sign (β#β). you can also slap a comment at the end of any line, again by delimiting the comment from the rest of the line with a pound sign.
Example 1. Comments in a Configuration File
# This is a comment
ACCEPT net $FW tcp www #This is an end-of-line comment
Important β οΈ except inshorewall.conf(5)[1] andparams(5)[2], if a comment ends with a backslash ("\"), the next line will also be treated as a comment. see Line Continuation below.
π«§ BLANK LINES π«§
most of the configuration files are organized into space-separated columns. so if you don't want to supply a value in a column but you do want to supply a value in a following column, just enter - to make the column appear empty. easy. π
Example:
#INTERFACE BROADCAST OPTIONS
br0 - routeback
π¦ LINE CONTINUATION π¦
lines 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 firewall
Important β οΈ what follows does NOT apply toshorewall-params(5)[31] andshorewall.conf(5)[1].
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 873
the 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". and because the third continuation line does not end with a comma or colon, the leading white space in the last line is not ignored. sneaky, right? π
Important β οΈ a trailing backslash is not ignored in a comment. so the continued rule above can be commented out with a single'#'like this:#ACTION SOURCE DEST PROTO DPORT #ACCEPT net:\ 206.124.146.177,\ 206.124.146.178,\ 206.124.146.180\ dmz tcp 873
π ALTERNATIVE SPECIFICATION OF COLUMN VALUES π
some of the configuration files now have a large number of columns. and that makes it super awkward to specify a value for one of the right-most columns, because you have to have the exact correct number of intervening - columns. not the vibe. π
this problem is addressed by allowing column values to be specified as column-name/value pairs.
and 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=value
column-name=>value
column-name:value
the 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:1024
Lowkey the biggest glow-up in Shorewall 5.0.3 was a naming thing, and honestly? It ate. β¨
Back in the day the sample config files and the man pages were kind of doing their own thing with column names β like, one of them would call it one thing in the column headings and something else entirely in the alternate specification format. Not anymore bestie. In Shorewall 5.0.3, both the sample configuration files and the man pages got updated so they use the same column names in both places:
- the column headings, and
- the alternate specification format.
Same names. Same everywhere. Consistency is the vibe and we are obsessed. π¦
The following table shows the column names for each of the table-oriented configuration files. π
Note
It's giving "one source of truth" and honestly every config file wishes it was this organised. π
Okay bestie, quick vibe check: column names are case-insensitive. So ACTION, Action, and action are all the same girl π
. Periodt.
Here's the full cheat sheet of which file takes which column names β keep this open, you'll need it:
accountingβaction,chain,source,dest,proto,dport,sport,user,mark,ipsec,headersconntrackβaction,source,dest,proto,dport,sport,user,switchblacklistβnetworks,proto,port,optionsblrulesβaction,source,dest,proto,dport,sport,origdest,rate,user,mark,connlimit,time,headers,switch,helperecnβinterface,hosts. Beginning with Shorewall 4.5.4,hostis a synonym forhosts. πhostsβzone,hosts,options. Beginning with Shorewall 4.5.4,hostis a synonym forhosts. π¦interfacesβzone,interface,broadcast,optionsmaclistβdisposition,interface,mac,addressesmangleβaction,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headersmasqβinterface,source,address,proto,port,ipsec,mark,user,switchnatβexternal,interface,internal,allints,localnetmapβtype,net1,interface,net2,net3,proto,dport,sportnotrackβsource,dest,proto,dport,sport,userpolicyβsource,dest,policy,loglevel,limit,connlimitprovidersβtable,number,mark,duplicate,interface,gateway,options,copyproxyarpandproxyndpβaddress,interface,external,haveroute,persistentrtrulesβsource,dest,provider,priorityroutesβprovider,dest,gateway,deviceroutestoppedβinterface,hosts,options,proto,dport,sportrulesβaction,source,dest,proto,dport,sport,origdest,rate,user,mark,connlimit,time,headers,switch,helper
Lowkey iconic that you scrolled this far, ngl. πβ¨ Keep going bestie, there's more where that came from π
secmarksβsecmark,chain,source,dest,proto,dport,sport,user,markπtcclassesβinterface,mark,rate,ceil,prio,optionstcdevicesβinterface,in_bandwidth,out_bandwidth,options,redirecttcfiltersβclass,source,dest,proto,dport,sport,tos,lengthtcinterfacesβinterface,type,in_bandwidth,out_bandwidthtcpriβband,proto,port,address,interface,helpertcrulesβmark,source,dest,proto,dport,sport,user,test,length,tos,connbytes,helper,headers. Beginning with Shorewall 4.5.3,actionis a synonym formark. (yes bestie, they're the same thing now, iconic)tosβsource,dest,proto,dport,sport,tos,marktunnelsβtype,zone,gateway,gateway_zone. Beginning with Shorewall 4.5.3,gatewaysis a synonym forgateway. Beginning with Shorewall 4.5.4,gateway_zonesis a synonym forgateway_zone.zonesβzone,type,options,in_options,out_options
Ok so example time, and this one's from the rules file:
#ACTION SOURCE DEST PROTO DPORT
DNAT net loc:10.0.0.1 tcp 80 ; mark="88"
And here's literally the same line in several equivalent formats β pick your fighter:
{ 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 comment 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 COLUMNS β°
Several of the files include a TIME column that lets you specify times when the rule is to be applied. The contents of this column is a list of timeelements separated by ampersands (&). (yes, ampersands, not commas β stay with me)
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. πcontiguousβ Added in Shorewall 5.0.12. Whentimestopis smaller than thetimestartvalue, match this as a single time period instead of distinct intervals. See the Examples below. β¨utcβ Times are expressed in Greenwich Mean Time.localtzβ Deprecated by the Netfilter team in favor ofkerneltz. Times are expressed in Local Civil Time (default).kerneltzβ Added in Shorewall 4.5.2. Times are expressed in Local Kernel Time (requiresiptables1.4.12 or later).weekdays=ddd[,ddd]...β where ddd is one ofMon,Tue,Wed,Thu,Fri,SatorSunmonthdays=dd[,dd],...β where dd is an ordinal day of the monthdatestart=yyyy[-mm[-dd[Thh[:mm[:ss]]]]]β Defines the starting date and time.datestop=yyyy[-mm[-dd[Thh[:mm[:ss]]]]]β Defines the ending date and time.
Examples:
To match on weekends, use:
weekdays=Sat,Sun
Or, to match (once) on a national holiday block:
datestart=2016-12-24&datestop=2016-12-27
Since 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:59
During Lunch Hour
The fourth Friday in the month:
weekdays=Fri&monthdays=22,23,24,25,26,27,28
Matching across days might not do what is expected. π
For instance,
weekdays=Mon×tart=23:00×top=01:00
Will 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 β like, if you would like "match for two hours from Monday 23:00 onwards" β you need to also specify the contiguous option in the example above. π
ποΈ SWITCHES ποΈ
There 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/switch1
You can turn it off again by:
echo 0 > /proc/net/nf_condition/switch1
If 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 reload. π¦
Shorewall requires that switch names:
- begin with a letter and be composed of letters, digits, underscore (
_) or hyphen (-); and - be 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
π FILES π
/etc/shorewall[6]/*
π NOTES π
okay bestie, this is the part where we list every single file that got its own lil manpage moment π these are the cross-references, the little "go read this next" links. Don't skip them, they're literally the receipts π§Ύ
/etc/shorewall/shorewall.confand/etc/shorewall6/shorewall6.confβ https://shorewall.org/manpages/shorewall.conf.html/etc/shorewall[6]/paramsβ https://shorewall.org/manpages/shorewall-params.html/etc/shorewall[6]/zonesβ https://shorewall.org/manpages/shorewall-zones.html/etc/shorewall[6]/policyβ https://shorewall.org/manpages/shorewall-policy.html/etc/shorewall[6]/interfacesβ https://shorewall.org/manpages/shorewall-interfaces.html/etc/shorewall[6]/hostsβ https://shorewall.org/manpages/shorewall-hosts.html/etc/shorewall[6]/masqβ https://shorewall.org/manpages/shorewall-masq.html/etc/shorewall[6]/mangleβ https://shorewall.org/manpages/shorewall-mangle.html/etc/shorewall[6]/rulesβ https://shorewall.org/manpages/shorewall-rules.html/etc/shorewall[6]/natβ https://shorewall.org/manpages/shorewall-nat.html/etc/shorewall6/proxyarpβ https://shorewall.org/manpages/shorewall-proxyarp.html/etc/shorewall6/proxyndpβ https://shorewall.org/manpages/shorewall-proxyndp.html/etc/shorewall[6]/tcrulesβ https://shorewall.org/manpages/shorewall-tcrules.html/etc/shorewall[6]/tosβ https://shorewall.org/manpages/shorewall-tos.html/etc/shorewall[6]/tunnelsβ https://shorewall.org/manpages/shorewall-tunnels.html/etc/shorewall[6]/blacklistβ https://shorewall.org/manpages/shorewall-blacklist.html/etc/shorewall/ecnβ https://shorewall.org/manpages/shorewall-ecn.html/etc/shorewall/accountingβ https://shorewall.org/manpages/shorewall-accounting.html/etc/shorewall[6]/actionsβ https://shorewall.org/manpages/shorewall-actions.html/etc/shorewall[6]/providersβ https://shorewall.org/manpages/???/etc/shorewall[6]/rtrulesβ https://shorewall.org/manpages/shorewall-rtrules.html/etc/shorewall[6]/tcdevicesβ https://shorewall.org/manpages/shorewall-tcdevices.html/etc/shorewall[6]/tcclassesβ https://shorewall.org/manpages/shorewall-tcclasses.html/etc/shorewall[6]/tcfiltersβ https://shorewall.org/manpages/shorewall-tcfilters.html/etc/shorewall[6]/tcinterfacesβ https://shorewall.org/manpages/shorewall-tcinterfaces.html/etc/shorewall[6]/tcpriβ https://shorewall.org/manpages/shorewall-tcpri.html/etc/shorewall[6]/secmarksβ https://shorewall.org/manpages/shorewall-secmarks.html/etc/shorewall[6]/vardirβ https://shorewall.org/manpages/shorewall-vardir.html/etc/shorewall/arprulesβ https://shorewall.org/manpages/shorewall-arprules.html/etc/shorewall[6]/snatβ https://shorewall.org/manpages/shorewall-snat.html- shorewall-params(5) β https://shorewall.org/manpages/shorewall-params.html
- shorewall-rules β https://shorewall.org/manpages/shorewall-rules.html
quick heads-up, bestie: number 20 is literally showing???as its URL in the original. Not me being lazy, not a typo I introduced β that's just how it is. Respect the???π«‘β¨
and that's a wrap on SHOREWALL-FILES(5) π this whole thing lives in the Configuration Files corner of the world, dated 09/24/2020, and it's giving "manpage that wants you to actually read it". go configure something iconic π π
π¦ where this page comes from
- alpine 3.22: shorewall-doc 5.2.8-r1 Β· GPL-2.0-or-later
- alpine 3.23: shorewall-doc 5.2.8-r1 Β· GPL-2.0-or-later
- alpine 3.24: shorewall-doc 5.2.8-r1 Β· GPL-2.0-or-later
- debian bookworm: shorewall 5.2.8-2 Β· GPL-2.0-or-later
- debian trixie: shorewall 5.2.8-6 Β· GPL-2.0-or-later
- fedora 43: shorewall 5.2.8-17.fc43 Β· GPL-2.0-or-later
- fedora 44: shorewall 5.2.8-18.fc44 Β· GPL-2.0-or-later
- nixos 26.05: shorewall 5.2.8
- nixpkgs unstable: shorewall 5.2.8
- ubuntu noble: shorewall 5.2.8-5 Β· GPL-2.0-or-later
- ubuntu questing: shorewall 5.2.8-6
- ubuntu resolute: shorewall 5.2.8-6build1 Β· GPL-2.0-or-later
- ubuntu stonking: shorewall 5.2.8-6build1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms