bindsnoop(8)
๐ 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
- alpine 3.24: bcc-doc 0.36.1-r1 ยท Apache-2.0
- nixpkgs unstable: bcc 0.37.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 ยท Apache-2.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 ยท Apache-2.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 ยท Apache-2.0
- opensuse-leap 16.0: bcc-tools 0.35.0-160000.2.2 ยท Apache-2.0
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms