SHOREWALL-EXCLUSION(5)
πΈ NAME πΈ
Okay so this is SHOREWALL-EXCLUSION(5), straight outta the Configuration Files manual, and it's about one thing and one thing only: exclusion π
β like, how to exclude a whole set of hosts from a definition in a shorewall configuration file. Slay, honestly.
β¨ SYNOPSIS β¨
!address-or-range[,address-or-range]...
!zone-name[,zone-name]...
π DESCRIPTION π
So, form one is the one you reach for when you wanna exclude one or more addresses from a definition. You slap a ! (exclamation point, iconic) at the front, and then a comma-separated list of addresses right after it. π
The addresses can be:
- single host addresses, like
192.168.1.4 - network addresses in CIDR format, like
192.168.1.0/24
And if your kernel and iptables come with iprange support, you can also specify ranges of ip addresses in the form lowaddress-highaddress β so like 192.168.1.3-192.168.1.12. π¦
No embedded white-space is allowed. π« Like, none. Not even one. Don't do it.
Exclusion can also show up after a list of addresses and/or address ranges. When it does, the final list of address is formed by taking the first list and then removing the addresses defined in the exclusion. So it's giving "start with everything, then subtract". β¨
Beginning in Shorewall 4.4.13, form two of exclusion is allowed after all and any in the SOURCE and DEST columns of shorewall-rules[1](5). It lets you omit arbitrary zones from the list that those key words generate. So useful. Obsessed. π
Warning β οΈ If you omit a sub-zone and there is an explicit or explicit CONTINUE policy, a connection to/from that zone can still be matched by the rule generated for a parent zone. Yeah, that's the whole point of the warning β read it twice bestie.
For example: π
/etc/shorewall/zones:
#ZONE TYPE
z1 ip
z2:z1 ip
...
/etc/shorewall/policy:
#SOURCE DEST POLICY
z1 net CONTINUE
z2 net REJECT
/etc/shorewall/rules:
#ACTION SOURCE DEST PROTO DPORT
ACCEPT all!z2 net tcp 22
In this case, SSH connections from z2 to net will be accepted by the generated z1 to net ACCEPT rule. π«Ά
In most contexts, ipset names can be used as an address-or-range. Beginning with Shorewall 4.4.14, ipset lists enclosed in +[...] may also be included (see shorewall-ipsets[2] (5)). π The semantics of these lists when used in an exclusion go like this:
!+[set1,set2,...setN]produces a packet match if the packet does not match at least one of the sets. In other words, it is like NOT matchset1OR NOT matchset2... OR NOT matchsetN.+[!set1,!set2,...!setN]produces a packet match if the packet does not match any of the sets. In other words, it is like NOT matchset1AND NOT matchset2... AND NOT matchsetN.
π EXAMPLES π
IPv4 Example 1 - All IPv4 addresses except 192.168.3.4
!192.168.3.4
IPv4 Example 2 - All IPv4 addresses except the network 192.168.1.0/24 and the host 10.2.3.4
!192.168.1.0/24,10.1.3.4
IPv4 Example 3 - All IPv4 addresses except the range 192.168.1.3-192.168.1.12 and the network 10.0.0.0/8
!192.168.1.3-192.168.1.12,10.0.0.0/8
IPv4 Example 4 - The network 192.168.1.0/24 except hosts 192.168.1.3 and 192.168.1.9
192.168.1.0/24!192.168.1.3,192.168.1.9
Example 5 - All parent zones except loc
any!loc
π¦ FILES π¦
/etc/shorewall/hosts/etc/shorewall/masq/etc/shorewall/rules/etc/shorewall/tcrules
π SEE ALSO π
π NOTES π
shorewall-ruleshttps://shorewall.org/manpages/shorewall-rules.htmlshorewall-ipsetshttps://shorewall.org/manpages/shorewall-ipsets.html
And that's the whole page, bestie π«Ά this was SHOREWALL-EXCLUSION(5) from the Configuration Files manual, dated 09/24/2020. Go exclude something (responsibly) π
β¨
π¦ where this page comes from
- alpine 3.22: shorewall6-doc 5.2.8-r1 Β· GPL-2.0-or-later
- alpine 3.23: shorewall6-doc 5.2.8-r1 Β· GPL-2.0-or-later
- alpine 3.24: shorewall6-doc 5.2.8-r1 Β· GPL-2.0-or-later
- debian bookworm: shorewall6 5.2.8-2 Β· GPL-2.0-or-later
- debian trixie: shorewall6 5.2.8-6 Β· GPL-2.0-or-later
- fedora 43: shorewall6 5.2.8-17.fc43 Β· GPL-2.0-or-later
- fedora 44: shorewall6 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: shorewall6 5.2.8-5 Β· GPL-2.0-or-later
- ubuntu questing: shorewall6 5.2.8-6
- ubuntu resolute: shorewall6 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