From nftables wiki
Jump to: navigation, search

Counters are optional in nftables, thus, you need to explicitly specify them in the rule if you want them.

The following example allows you to account all tcp traffic that you machine receives:

% nft add rule filter input ip protocol tcp counter

An interesting feature of the counter action is that its position in the rule syntax matters. This rule is not equivalent to the previous rule:

% nft add rule filter input counter ip protocol tcp

The rule is evaluated from the left to the right, so any kind of packet will update the counters, not only TCP packets.