Scroll to navigation



exclusion - Exclude a set of hosts from a definition in a shorewall configuration file.





The first form of exclusion is used when you wish to exclude one or more addresses from a definition. An exclamation point is followed by a comma-separated list of addresses. The addresses may be single host addresses (e.g., or they may be network addresses in CIDR format (e.g., If your kernel and iptables include iprange support, you may also specify ranges of ip addresses of the form lowaddress-highaddress

No embedded white-space is allowed.

Exclusion can appear after a list of addresses and/or address ranges. In that case, the final list of address is formed by taking the first list and then removing the addresses defined in the exclusion.

Beginning in Shorewall 4.4.13, the second form of exclusion is allowed after all and any in the SOURCE and DEST columns of shorewall-rules[1](5). It allows you to omit arbitrary zones from the list generated by those key words.


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.

For example:


#ZONE          TYPE
z1             ip
z2:z1          ip


#SOURCE         DEST          POLICY
z1              net           CONTINUE
z2              net           REJECT


#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 are as follows:

•!+[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 match set1 OR NOT match set2 ... OR NOT match setN.

•+[!set1,!set2,...!setN] produces a packet match if the packet does not match any of the sets. In other words, it is like NOT match set1 AND NOT match set2 ... AND NOT match setN.


IPv4 Example 1 - All IPv4 addresses except


IPv4 Example 2 - All IPv4 addresses except the network and the host


IPv4 Example 3 - All IPv4 addresses except the range and the network


IPv4 Example 4 - The network except hosts and!,

Example 5 - All parent zones except loc










09/24/2020 Configuration Files