proc-trace-net

Building from Source

Three ways to get a binary โ€” pick the one that fits your setup.

๐Ÿณ Docker Recommended

No local Go install required. Produces static binaries for amd64 and arm64 in one command via build.sh.

โšก Quick Build Go required

One line with a local Go install. Output is a native binary for your current platform.

๐Ÿ“ฆ Static Binary Go required

Fully static with CGO_ENABLED=0. Copy the binary to any Linux system of the same architecture โ€” no runtime dependencies.

Kernel & Runtime

proc-trace-net uses the Linux conntrack netlink socket โ€” a standard kernel interface available on virtually every modern distribution that runs Docker, iptables, or nftables.

Requirement Details Status
Linux kernel ≥ 3.6 conntrack multicast groups stable since 3.x. Any distro running Docker or iptables qualifies. โœ“ universal
CONFIG_NF_CONNTRACK=y Standard on Ubuntu, Debian, Fedora, RHEL, Arch, Alpine โ€” any system using iptables/nftables/Docker. โœ“ default on
CAP_NET_ADMIN Required to bind the conntrack netlink socket. Run as root, or grant with setcap. โœ“ root / setcap
Go 1.22+ Only needed for the from-source build methods. The Docker build uses golang:1.22-alpine internally. โœ“ optional
Docker Only needed for the build.sh Docker method. Any recent Docker Engine with buildx support works. โœ“ optional

Multi-arch build via build.sh

Clones the repo, runs the build inside a golang:1.22-alpine container, and drops two static binaries into ./dist/ โ€” no local Go toolchain needed.

  1. Clone the repo
    Gets the source and the build.sh script.
  2. Mark build.sh executable and run it
    The script handles everything: image pull, cross-compilation for both architectures, and output placement.
  3. Find your binary in ./dist/
    Copy the right arch binary to /usr/local/bin/ or wherever you like.
build.sh โ€” docker cross-compile
# Clone
โฏ git clone https://github.com/binRick/proc-trace-net.git
โฏ cd proc-trace-net

# Build
โฏ chmod +x build.sh
โฏ ./build.sh
Building proc-trace-net ...
  โ†’ linux/amd64
  โ†’ linux/arm64
Done. Binaries in ./dist/:
  proc-trace-net-linux-amd64  (3.8 MB)
  proc-trace-net-linux-arm64  (3.6 MB)

# Install
โฏ sudo cp dist/proc-trace-net-linux-amd64 /usr/local/bin/proc-trace-net
โฏ proc-trace-net -h
๐ŸŒ proc-trace-net dev โ€” system-wide network connection tracer for Linux

With local Go install

If you already have Go 1.22+ installed, this is the fastest path. Use CGO_ENABLED=0 and strip flags for a fully static binary with no runtime dependencies.

go build โ€” static
โฏ git clone https://github.com/binRick/proc-trace-net.git
โฏ cd proc-trace-net
โฏ CGO_ENABLED=0 go build -ldflags="-s -w" -o proc-trace-net .
โฏ sudo mv proc-trace-net /usr/local/bin/

# Confirm: no dynamic libraries
โฏ file proc-trace-net
proc-trace-net: ELF 64-bit LSB executable, x86-64, statically linked, stripped

Build for a different architecture

Go's built-in cross-compilation support makes it trivial to build binaries for other Linux architectures. Set GOOS and GOARCH before building.

TargetGOOSGOARCHCommand
Linux x86-64 linux amd64 GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o proc-trace-net-linux-amd64 .
Linux arm64 linux arm64 GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-s -w" -o proc-trace-net-linux-arm64 .

Note: proc-trace-net uses NETLINK_NETFILTER which is Linux-specific. Cross-compiling for non-Linux targets will succeed but the binary will not run.

What the flags do

The recommended build uses a specific set of Go flags. Here's what each one does.

CGO_ENABLED=0 Disables CGo, forcing a purely Go build with no C library linkage. The resulting binary is fully static โ€” no libc, no runtime dependencies. Copy it to any Linux system and it runs.
-ldflags="-s -w" -s strips the symbol table; -w strips DWARF debug information. Together they reduce binary size by ~30% with no impact on runtime behavior.
-trimpath Removes local filesystem paths from the binary (optional). Useful for reproducible builds and to avoid leaking your build directory structure in stack traces.

Grant CAP_NET_ADMIN with setcap

Instead of running as root every time, you can grant the specific capability the tool needs. The binary will be usable by any user on the system.

setcap โ€” drop root requirement
# Grant the capability (one-time, as root)
โฏ sudo setcap cap_net_admin+eip /usr/local/bin/proc-trace-net

# Verify
โฏ getcap /usr/local/bin/proc-trace-net
/usr/local/bin/proc-trace-net cap_net_admin=eip

# Now run as a normal user
โฏ proc-trace-net -ct
3892 curl  TCP  10.0.2.15:54321  โ†’  93.184.216.34:443