TC-FW(8)
โจ NAME โจ
Firewall mark classifier in tc(8) ๐ okay so this page is all about fw, the fwmark traffic control filter. It's giving packet sorting based on marks, and it's honestly iconic ๐
tc filter ... fw [ classid CLASSID ] [ action ACTION_SPEC ]
๐ธ SYNOPSIS ๐ธ
Here's the shape of the command. Anything in italics is a placeholder you swap out for your own stuff ๐ซถ
tc filter ... fw [ classid CLASSID ] [ action ACTION_SPEC ]
๐ DESCRIPTION ๐
Okay so bestie, the fw filter lets you classify packets based on a fwmark that was already set by iptables ๐ฅ If the masked value of the fwmark matches the filter's masked handle, the filter matches. By default, all 32 bits of the handle and the fwmark get masked, so every single bit has to line up.
iptables can mark single packets with the MARK target, or mark whole connections using CONNMARK. Lowkey the best part is that you don't have to do all the heavy lifting inside tc itself ๐ง You can keep your packet filtering and classification in one place, which means you might only have to match a packet once. And if you're someone who knows iptables but not tc, this filter means way less struggle when you're adding QoS to your setups โจ The vibe is literally efficiency.
๐ฆ OPTIONS ๐ฆ
classid CLASSIDโ Pushes matching packets into the class identified byCLASSID๐action ACTION_SPECโ Applies an action from the generic actions framework to matching packets ๐
๐ EXAMPLES ๐
Let's look at this together, okay? Take e.g. the following tc filter statement:
tc filter add ... handle 6 fw classid 1:1
This will match if the packet's fwmark value is 6. No cap, that's the whole thing ๐ญ
Here's a sample iptables statement that marks packets coming in on eth0:
iptables -t mangle -A PREROUTING -i eth0 -j MARK --set-mark 6
Now, if you want to set specific bits of the packet's fwmark, you can use the skbedit action ๐ For example, to only set one bit of the fwmark without changing any other bit:
tc filter add ... action skbedit mark 0x8/0x8
The fw filter can then match on that bit by masking the handle:
tc filter add ... handle 0x8/0x8 fw action drop
This is super useful when different bits of the fwmark are assigned different meanings ๐
๐ SEE ALSO ๐
Want more? Check out these:
Bestie, that's the whole page ๐ Source: iproute2, last updated 21 Oct 2015 ๐ซถโจ
๐ฆ where this page comes from
- alpine 3.22: iproute2-doc 6.15.0-r0 ยท GPL-2.0-or-later
- alpine 3.23: iproute2-doc 6.17.0-r0 ยท GPL-2.0-or-later
- alpine 3.24: iproute2-doc 7.0.0-r0 ยท GPL-2.0-or-later
- arch rolling: iproute2 7.2.0-1
- arch rolling: iproute2 7.3.0-1 ยท GPL-2.0-or-later
- centos-stream 10: iproute-tc 7.0.0-2.el10 ยท GPL-2.0-or-later
- centos-stream 9: iproute-tc 6.17.0-3.el9 ยท GPL-2.0-or-later
- debian bookworm: iproute2 6.1.0-3 ยท GPL-2.0-only
- debian trixie: iproute2 6.15.0-1 ยท GPL-2.0-only
- fedora 43: iproute-tc 6.14.0-2.fc43 ยท GPL-2.0-or-later
- fedora 44: iproute-tc 6.17.0-2.fc44 ยท GPL-2.0-or-later
- nixos 26.05: iproute2 7.0.0
- nixpkgs unstable: iproute2 7.2.0
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- opensuse-leap 16.0: iproute2 6.12-160000.4.1 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6 ยท GPL-2.0-only
- ubuntu noble: iproute2 6.1.0-1ubuntu6.4 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2
- ubuntu questing: iproute2 6.16.0-1ubuntu2.1 ยท GPL-2.0-only
- ubuntu questing: iproute2 6.16.0-1ubuntu2.2
- ubuntu resolute: iproute2 6.19.0-1ubuntu1 ยท GPL-2.0-only
- ubuntu resolute: iproute2 6.19.0-1ubuntu1.1 ยท GPL-2.0-only
- ubuntu stonking: iproute2 7.2.0-1ubuntu1 ยท GPL-2.0-only
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms