NFBPF_COMPILE(8)

πŸ“¦
version 1.8.11 Β· 3 versions
, in centos-stream 10, fedora 43, fedora 44

✨ NFBPF_COMPILE ✨

okay bestie, welcome to the nfbpf_compile page πŸ’… this one lives in the iptables world (version 1.8.11, if you're keeping receipts) and it's genuinely such a useful little goblin. come sit, we're gonna get you fluent in it 🫢


🌸 NAME 🌸

nfbpf_compile β€” generate bytecode for use with xt_bpf

like. it makes BPF bytecode. for xt_bpf. that's the whole job and she does it beautifully 😌


πŸŽ€ SYNOPSIS πŸŽ€

nfbpf_compile [ LLTYPE ] PROGRAM

LLTYPE := { EN10MB | RAW | SLIP | ...  }

so you can pass an LLTYPE, or you can just... not, and let her pick 🧚 either way PROGRAM is the main character here.


πŸ’– DESCRIPTION πŸ’–

The nfbpf_compile utility aids in generating BPF byte code suitable for passing to the iptables bpf match. no cap β€” that's literally her entire purpose and she's obsessed with it ✨


πŸ‘‘ OPTIONS πŸ‘‘

  • LLTYPE β€” the link-layer header type to operate on, bestie. it's a name as defined in <pcap/dlt.h>, but with the leading DLT_ prefix stripped off (yes, they really do just chop it off, iconic honestly). for use with iptables, RAW should be the right choice β€” it's also the default if not specified 🌈 so if you say nothing, she's already giving RAW.
  • PROGRAM β€” the BPF expression to compile πŸ¦‹ peep pcap-filter(7) for a description of the language, because that's where the grammar lives.

πŸ’€ EXIT STATUS πŸ’€

The program returns 0 on success, 1 otherwise. so 0 is the slay, 1 is the "not me" 😭


πŸ“ EXAMPLE πŸ“

Match incoming TCP packets with size bigger than 100 bytes:

bpf=$(nfbpf_compile 'tcp and greater 100')
iptables -A INPUT -m bpf --bytecode "$bpf" -j ACCEPT

see how she just hands you the bytecode and you pipe it straight into --bytecode?? that's the vibe fr fr πŸ”₯

The description of bpf match in iptables-extensions(8) lists a few more examples, so if you want more inspo, that's your next stop πŸ“š


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie!! πŸ’œ this was iptables 1.8.11's NFBPF_COMPILE(8) β€” go forth and compile some bytecode, you absolute main character πŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from