NPFLOG(4)

πŸ“¦ version 11.0, in nixpkgs unstable

πŸ’– NPFLOG(4) πŸ’–

okay so this is the npflog page from the Kernel Interfaces Manual, section 4, bestie β€” buckle up πŸŽ€


✨ NAME ✨

npflog β€” the packet filter logging interface, aka the lil bestie that shows you everything npf is logging πŸ”₯


πŸ¦‹ SYNOPSIS πŸ¦‹

pseudo-device npflog

that's it. that's the whole vibe. a single pseudo-device line, slay πŸ’…


🌸 DESCRIPTION 🌸

okay so the npflog interface is a pseudo-device and what it does β€” its whole main character job β€” is make visible all the packets that get logged by the npf(7) packet filter. like, every logged packet? now you can see it. no cap πŸ‘‘

and bestie you've got two ways to actually consume them:

  • monitor the logged packets in real time by invoking tcpdump(8) on the npflog interface 🫢
  • or store them to disk using npfd(8) πŸ’Ύ

the npflog0 interface gets created automatically at boot if npf(7) is enabled β€” yes, it just shows up, iconic. and if you want more instances? you can create further instances using ifconfig(8). go off ✨


🧚 the header struct (iykyk) 🧚

every packet you retrieve on this interface comes with a header attached, and that header presently matches the format used by pf(4). what does that header do? it documents all of this for the packet that was logged:

  • the address family
  • the interface name
  • the rule number
  • the reason
  • the action
  • the direction

and the structure looks exactly like this, character for character, don't touch it:

struct npfloghdr {
        uint8_t         length;
        sa_family_t     af;
        uint8_t         action;
        uint8_t         reason;
        char            ifname[IFNAMSIZ];
        char            ruleset[NPFLOG_RULESET_NAME_SIZE];
        uint32_t        rulenr;
        uint32_t        subrulenr;
        uint32_t        uid;
        uint32_t        pid;
        uint32_t        rule_uid;
        uint32_t        rule_pid;
        uint8_t         dir;
        uint8_t         pad[3];
};

look at that pad[3] just chilling at the end. king behavior honestly πŸ‘‘πŸ’€


πŸ”₯ EXAMPLES πŸ”₯

want to monitor all the packets logged on the default interface? say less:

# tcpdump -n -e -tttt -i npflog0

that's the whole recipe. -n -e -tttt -i npflog0. copy it, paste it, watch the packets roll in πŸ“


🌈 SEE ALSO 🌈

the whole friend group, fr fr:

go read those too, they're literally all connected πŸ’œ


πŸ’€ HISTORY πŸ’€

the npflog device first appeared in NetBSD 6.0. ancient. vintage. a legacy icon πŸŽ€


ngl, that's the whole page β€” nothing skipped, nothing hidden, every flag and every field accounted for πŸ’…

this lil rewrite came to you from the Debian build, dated June 29, 2023 β€” mwah, bye bestie 🫢✨

πŸ“¦ where this page comes from
  • nixpkgs unstable: netbsd-source 11.0
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms