bindsnoop(8)

๐Ÿ“ฆ version 0.36.1, in centos-stream 10, centos-stream 9, fedora 43, fedora 44

๐ŸŽ€ bindsnoop(8) ๐ŸŽ€

๐Ÿ’… NAME ๐Ÿ’…

okay so bindsnoop is the tool that traces bind() system calls ๐Ÿฆ‹ It's giving "I see every single socket getting bound" energy โœจ

๐Ÿงš SYNOPSIS ๐Ÿงš

bindsnoop [-h] [-w] [-t] [-p PID] [-P PORT] [-E] [-U] [-u UID] [--count]
[--cgroupmap MAP] [--mntnsmap MNTNSMAP]

๐ŸŒธ DESCRIPTION ๐ŸŒธ

bestie, listen ๐Ÿ‘‚ bindsnoop reports the socket options that get set before the bind call, because those options can totally change how bind behaves. It's the tea before the tea โ˜•โœจ

๐Ÿ“‹ REQUIREMENTS ๐Ÿ“‹

You'll need CONFIG_BPF and bcc ๐Ÿ’œ no cap, nothing works without them ๐Ÿ™ˆ

โœจ OPTIONS โœจ

  • -h, --help โ€” shows the help message and then exits ๐Ÿ’–
  • -t, --timestamp โ€” adds a timestamp to the output โฐ
  • -w, --wide โ€” wider columns so IPv6 addresses actually fit ๐ŸŒˆ
  • -p PID, --pid PID โ€” only traces this PID ๐ŸŽฏ
  • -P PORT, --port PORT โ€” a comma-separated list of ports to trace ๐Ÿ“
  • --cgroupmap MAP โ€” traces the cgroups that live in this BPF map ๐Ÿง
  • --mntnsmap MNTNSMAP โ€” traces the mount namespaces that live in this BPF map ๐Ÿ—‚๏ธ
  • -E, --errors โ€” includes errors in the output ๐Ÿ™ˆ
  • -U, --print-uid โ€” includes the UID in the output ๐Ÿชช
  • -u UID, --uid UID โ€” only traces this UID ๐Ÿ‘‘
  • --count โ€” counts binds per source IP and port ๐Ÿ“Š

๐Ÿฆ‹ EXAMPLES ๐Ÿฆ‹

Here's how you use it, bestie ๐Ÿ’…

  • Trace all IPv4 and IPv6 bind()s: bindsnoop
  • Include timestamps: bindsnoop -t
  • Trace PID 181: bindsnoop -p 181
  • Trace port 80: bindsnoop -P 80
  • Trace port 80 and 81: bindsnoop -P 80,81
  • Include UID: bindsnoop -U
  • Trace UID 1000: bindsnoop -u 1000
  • Report bind errors: bindsnoop -E
  • Count binds per src ip: bindsnoop --count

๐Ÿ”ฎ Socket flags ๐Ÿ”ฎ

So this one is literally the main event ๐Ÿ˜ญ It traces IPv4 and IPv6 bind system calls and reports the socket options that would impact how bind behaves:

SOL_IP IP_FREEBIND              F....

SOL_IP IP_TRANSPARENT           .T...

SOL_IP IP_BIND_ADDRESS_NO_PORT  ..N..

SOL_SOCKET SO_REUSEADDR         ...R.

SOL_SOCKET SO_REUSEPORT         ....r
โš ๏ธ Heads up, babe: SO_BINDTODEVICE interface is reported as an "IF" index. Don't skip this part ๐Ÿฅบ

๐ŸŒˆ SOURCE ๐ŸŒˆ

This one is from bcc, obviously ๐Ÿ’–

https://github.com/iovisor/bcc

Also check the bcc distribution for a companion _examples.txt file. It has example usage, output, and commentary for this tool, and it's honestly so helpful ๐Ÿซถ

๐Ÿ’ป OS ๐Ÿ’ป

Linux, only. Sorry, Mac girlies ๐ŸŽ๐Ÿ™ˆ

๐Ÿงช STABILITY ๐Ÿงช

Unstable, it's still in development ๐Ÿšง So be a little careful ๐Ÿ’€

๐Ÿ‘ฉโ€๐Ÿ’ป AUTHOR ๐Ÿ‘ฉโ€๐Ÿ’ป

Pavel Dubovitsky is the genius behind this ๐Ÿ‘‘

๐Ÿ”— SEE ALSO ๐Ÿ”—

tcpaccept(8) ๐Ÿฆ‹


Okay that's the whole tea ๐Ÿซ– This page is from bcc, dated 12 February 2020, and it's all about bindsnoop(8) ๐Ÿ’œ Periodt โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from