SHOREWALL6-CONNTRAC(5)

πŸ“¦
version 5.2.8 Β· 2 versions
  • 5.2.8 Β· alpine 3.22, alpine 3.23, alpine 3.24, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu noble, ubuntu questing, ubuntu resolute (latest)
  • 5.2.3.4 Β· ubuntu jammy
, in alpine 3.22, alpine 3.23, alpine 3.24, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu noble, ubuntu questing, ubuntu resolute

πŸ’… SHOREWALL6-CONNTRAC(5) πŸ’…

okay so this is a Configuration Files man page β€” section 5 β€” and it's all about conntrack. bestie, this one is LONG (it comes in two parts and we're on part one), so grab a snack, hydrate, and let's go πŸ“βœ¨


πŸŽ€ NAME πŸŽ€

conntrack β€” the shorewall conntrack file. that's it, that's the name. short, sweet, iconic.

πŸ“‹ SYNOPSIS πŸ“‹

/etc/shorewall[6]/conntrack

πŸ’– DESCRIPTION πŸ’–

okay storytime, because the lore here is real. The original intent of the notrack file was to exempt certain traffic from Netfilter connection tracking β€” literally, traffic matching entries in the file was not to be tracked. hence the name, iykyk. 🌸

then it got a glow-up. The role of the file was expanded in Shorewall 4.4.27 to include all rules that can be added in the Netfilter raw table. and then in 4.5.7, the file's name was changed to conntrack. main character energy fr fr. πŸ¦‹

The file supports three different column layouts: FORMAT 1, FORMAT 2, and FORMAT 3, with FORMAT 1 being the default. here's how the three differ, bestie:

  • in FORMAT 2 and 3, there is an additional leading ACTION column.
  • in FORMAT 3, the SOURCE column accepts no zone name; rather the ACTION column allows a SUFFIX that determines the chain(s) that the generated rule will be added to.

When an entry in the following form is encountered, the format of the following entries are assumed to be of the specified format. ✨

?FORMAT
      format

where format is either 1, 2 or 3.

FORMAT 3 was introduced in Shorewall 4.5.10. no cap. πŸ’…

Comments may be attached to Netfilter rules generated from entries in this file through the use of ?COMMENT lines. These lines begin with ?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 containing only ?COMMENT. πŸ’¬ lowkey a cute little feature.

The columns in the file are as follows (where the column name is followed by a different name in parentheses, the different name is used in the alternate specification syntax). okay, deep breath, here come the columns πŸ‘‘


⚑ ACTION ⚑

{NOTRACK|CT:helper:name[(arg=val[,...])|CT:ctevents:event[,...]|CT:expevents:new|CT:notrack|DROP|LOG|ULOG(ulog-parameters):NFLOG(nflog-parameters)|IP[6]TABLES(target)}[log-level[:log-tag]][:chain-designator]

This column is only present when FORMAT >= 2. Values other than NOTRACK or DROP require CT Targetsupport in your iptables and kernel. (yes, for real β€” go check, bestie.)

  • NOTRACK or CT:notrack β€” Disables connection tracking for this packet. If a log-level is specified, the packet will also be logged at that level.
  • CT:helper:name β€” Attach the helper identified by the name to this connection. This is more flexible than loading the conntrack helper with preset ports. If a log-level is specified, the packet will also be logged at that level. Beginning with Shorewall 4.6.10, the helper name is optional.
    • At this writing, the available helpers are:
      • amanda β€” Requires that the amanda netfilter helper is present.
      • ftp β€” Requires that the FTP netfilter helper is present.
      • irc β€” Requires that the IRC netfilter helper is present.
      • netbios-ns β€” Requires that the netbios_ns (sic) helper is present.
      • RAS and Q.931 β€” These require that the H323 netfilter helper is present.
      • pptp β€” Requires that the pptp netfilter helper is present.
      • sane β€” Requires that the SANE netfilter helper is present.
      • sip β€” Requires that the SIP netfilter helper is present.
      • snmp β€” Requires that the SNMP netfilter helper is present.
      • tftp β€” Requires that the TFTP netfilter helper is present.
    • May be followed by an option list of arg=val pairs in parentheses:
      • ctevents=event[,...] β€” Only generate the specified conntrack events for this connection. Possible event types are: new, related, destroy, reply, assured, protoinfo, helper, mark (this is connection mark, not packet mark), natseqinfo, and secmark. If more than one event is listed, the event list must be enclosed in parentheses (e.g., ctevents=(new,related)).
      • expevents=new β€” Only generate a new expectation events for this connection.
  • ctevents:event[,...] β€” Added in Shorewall 4.6.10. Only generate the specified conntrack events for this connection. Possible event types are: new, related, destroy, reply, assured, protoinfo, helper, mark (this is connection mark, not packet mark), natseqinfo, and secmark.
  • expevents=new β€” Added in Shorewall 4.6.10. Only generate new expectation events for this connection.
  • DROP β€” Added in Shorewall 4.5.10. Silently discard the packet. If a log-level is specified, the packet will also be logged at that level.
  • IP6TABLES(target) β€” IPv6 only. Added in Shorewall 4.6.0. Allows you to specify any iptables target with target options (e.g., "IP6TABLES(AUDIT --type drop)"). If the target is not one recognized by Shorewall, the following error message will be issued:
ERROR: Unknown target
                (target)

This error message may be eliminated by adding target as a builtin action in shorewall-actions[1](5).

  • IPTABLES(target) β€” IPv4 only. Added in Shorewall 4.6.0. Allows you to specify any iptables target with target options (e.g., "IPTABLES(AUDIT --type drop)"). If the target is not one recognized by Shorewall, the following error message will be issued:
ERROR: Unknown target
                (target)

This error message may be eliminated by adding target as a builtin action in shorewall-actions[1](5).

  • LOG β€” Added in Shoreawll 4.6.0. Logs the packet using the specified log-level and log-tag (if any). If no log-level is specified, then 'info' is assumed.
  • NFLOG β€” Added in Shoreawll 4.6.0. Queues the packet to a backend logging daemon using the NFLOG netfilter target with the specified nflog-parameters.
  • ULOG β€” IPv4 only. Added in Shoreawll 4.6.0. Queues the packet to a backend logging daemon using the ULOG netfilter target with the specified ulog-parameters.

When FORMAT = 1, this column is not present and the rule is processed as if NOTRACK had been entered in this column.

Beginning with Shorewall 4.5.10, when FORMAT = 3, this column can end with a colon followed by a chain-designator. The chain-designator can be one of the following:

  • P β€” The rule is added to the raw table PREROUTING chain. This is the default if no chain-designator is present.
  • O β€” The rule is added to the raw table OUTPUT chain.
  • PO or OP β€” The rule is added to the raw table PREROUTING and OUTPUT chains.

🌈 SOURCE (formats 1 and 2) 🌈

{zone[:interface][:address-list]}

where zone is the name of a zone, interface is an interface to that zone, and address-list is a comma-separated list of addresses (may contain exclusion β€” see shorewall-exclusion[2] (5)).

Beginning with Shorewall 4.5.7, all can be used as the zone name to mean all zones.

Beginning with Shorewall 4.5.10, all- can be used as the zone name to mean all off-firewall zones. 🫢


πŸ¦‹ SOURCE (format 3 prior to Shorewall 5.1.0) πŸ¦‹

{-|interface[:address-list]|address-list}

Where interface is an interface to that zone, and address-list is a comma-separated list of addresses (may contain exclusion β€” see shorewall-exclusion[2] (5)).


🧚 SOURCE (format 3 on Shorewall 5.1.0 and later) 🧚

{-|[source-spec[,...]]}

where source-spec is one of the following:

  • interface β€” Where interface is the logical name of an interface defined in shorewall-interface[3](5).
  • address[,...][exclusion] β€” where address may be:
    • A host or network IP address.
    • A MAC address in Shorewall format (preceded by a tilde ("~") and using dash ("-") as a separator.
    • The name of an ipset preceded by a plus sign ("+"). See shorewall-ipsets[4](5).

exclusion is described in shorewall-exclusion[2](5).

  • interface:address[,...][exclusion] β€” This form combines the preceding two and requires that both the incoming interface and source address match.
  • exclusion β€” See shorewall-exclusion[2] (5).

Beginning with Shorewall 5.1.0, multiple source-specs separated by commas may be specified provided that the following alternative forms are used:

(address[,...][exclusion])

interface:(address[,...][exclusion])

(exclusion)

πŸŽ€ DEST (Prior to Shorewall 5.1.0) πŸŽ€

{-|interface[:address-list]|address-list}

where address-list is a comma-separated list of addresses (may contain exclusion β€” see shorewall-exclusion[2] (5)).


πŸ‘‘ DEST (Shorewall 5.1.0 and later) πŸ‘‘

{-|dest-spec[,...]}

where dest-spec is one of the following:

  • interface β€” Where interface is the logical name of an interface defined in shorewall-interface[3](5).
  • address[,...][exclusion] β€” where address may be:
    • A host or network IP address.
    • A MAC address in Shorewall format (preceded by a tilde ("~") and using dash ("-") as a separator.
    • The name of an ipset preceded by a plus sign ("+"). See shorewall-ipsets[4](5).

exclusion is described in shorewall-exclusion[2](5).

  • interface:address[,...][exclusion] β€” This form combines the preceding two and requires that both the outgoing interface and destination address match.
  • exclusion β€” See shorewall-exclusion[2] (5).

Beginning with Shorewall 5.1.0, multiple source-specs separated by commas may be specified provided that the following alternative forms are used:

(address[,...][exclusion])

interface:(address[,...][exclusion])

(exclusion)

πŸ”₯ PROTO πŸ”₯

protocol-name-or-number[,...]

A protocol name from /etc/protocols or a protocol number. tcp and 6 may be optionally followed by :syn to match only the SYN packet (first packet in the three-way handshake). ✨

Beginning with Shorewall 4.5.12, this column can accept a comma-separated list of protocols and either proto or protos is accepted in the alternate input format.

Continuing on with the PROTO glow-up: starting with Shorewall 5.1.11, when you say tcp or 6 and your ACTION is CT, the compiler is gonna default you to :syn all on its own. But bestie, if you want your rule to match packets with any valid combo of TCP flags, you can just say tcp:all or 6:all and it'll do the thing. πŸ’…

πŸ“ DPORT β€” port-number/service-name-list

A comma-separated list of port numbers and/or service names, pulled straight from /etc/services. It can also include port ranges in the low-port:high-port shape β€” but only if your kernel and iptables have port range support, okay? ✨

This column used to be called DEST PORT(S) back in the day, fyi.

🌸 SPORT β€” port-number/service-name-list

Same vibe as DPORT, literally: a comma-separated list of port numbers and/or service names from /etc/services, and it may also include ranges of the form low-port:high-port if your kernel and iptables are port-range girlies.

Starting with Shorewall 4.5.15, you can drop a = in this column β€” but ONLY if the DPORT column isn't empty, capiche? What that does: the rule matches when either the source port or the destination port in a packet matches one of the ports you listed in DPORT. Heads up though β€” using = requires multi-port match in your iptables and kernel, no exceptions. 😭

This column used to be labelled SOURCE PORT(S).

πŸ¦‹ USER – [user][:group]

This column used to be named USER/GROUP, and you can only specify it if the SOURCE zone is $FW. It tells you the effective user id and/or group id of the process that's sending the traffic. πŸ‘‘

✨ SWITCH β€” [!]switch-name[={0|1}]

Added in Shorewall 4.5.10, and it lets you enable/disable a rule without needing to do a whole shorewall restart. The convenience?? Unmatched. πŸ™Œ

Here's the deal: the rule is enabled if the value stored in /proc/net/nf_condition/switch-name is 1. The rule is disabled if that file contains 0 (which is the default, btw). If you supply a !, the test gets inverted β€” so the rule is enabled when the file contains 0.

Inside the switch-name, @0 and @{0} get replaced by the name of the chain the rule is added to. And after all that ... expansion, the switch-name has to begin with a letter and can only be made of letters, decimal digits, underscores, or hyphens. Also switch names must be 30 characters or less in length. Not a suggestion, bestie. βœ‹

Switches are normally off. To turn one on:

echo 1 > /proc/net/nf_condition/switch-name

To turn it off again:

echo 0 > /proc/net/nf_condition/switch-name

Switch settings are retained over shorewall restart, which is honestly iconic of them.

When the switch-name is followed by =0 or =1, then the switch gets initialized to off or on respectively by the start command. Other commands do not affect the switch setting. Periodt.


🌈 EXAMPLE

IPv4 Example 1:

#ACTION                       SOURCE            DEST               PROTO            DPORT             SPORT               USER
CT:helper:ftp(expevents=new)  fw                -                  tcp              21

IPv4 Example 2 (Shorewall 4.5.10 or later):

Drop traffic to/from all zones to IP address 1.2.3.4

?FORMAT 2
#ACTION                       SOURCE             DEST               PROTO           DPORT             SPORT               USER
DROP                          all-:1.2.3.4       -
DROP                          all                1.2.3.4

or

?FORMAT 3
#ACTION                       SOURCE             DEST               PROTO           DPORT             SPORT               USER
DROP:P                        1.2.3.4            -
DROP:PO                       -                  1.2.3.4

IPv6 Example 1:

Use the FTP helper for TCP port 21 connections from the firewall itself.

FORMAT 2
#ACTION                       SOURCE            DEST               PROTO            DPORT             SPORT               USER
CT:helper:ftp(expevents=new)  fw                -                  tcp              21

IPv6 Example 2 (Shorewall 4.5.10 or later):

Drop traffic to/from all zones to IP address 2001:1.2.3::4

FORMAT 2
#ACTION                       SOURCE             DEST               PROTO           DPORT             SPORT               USER
DROP                          all-:2001:1.2.3::4 -
DROP                          all                2001:1.2.3::4

or

FORMAT 3
#ACTION                       SOURCE             DEST               PROTO           DPORT             SPORT               USER
DROP:P                        2001:1.2.3::4      -
DROP:PO                       -                  2001:1.2.3::4

πŸŽ€ FILES

  • /etc/shorewall/conntrack
  • /etc/shorewall6/conntrack

πŸ”₯ SEE ALSO

πŸ’– NOTES

  1. shorewall-actions https://shorewall.org/manpages/shorewall-actions.html
  2. shorewall-exclusion https://shorewall.org/manpages/shorewall-exclusion.html
  3. shorewall-interface https://shorewall.org/manpages/shorewall-interfaces.html
  4. shorewall-ipsets https://shorewall.org/manpages/shorewall-ipsets.html
  5. https://shorewall.org/configuration_file_basics.htm#Pairs https://shorewall.org/configuration_file_basics.htm#Pairs

okay that's the whole page bestie, we ate and left absolutely no crumbs 🫢 This one lives in the Configuration Files collection, it's from 09/24/2020, and its official glow-up name is SHOREWALL6-CONNTRAC(5) β€” go forth and configure, queen πŸ‘‘βœ¨