proc-trace-dns

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 dynamically linked — fine for dev use on the same machine.

📦 Static Binary Go required

Fully static, no libc dependency. Copy the binary to any Linux system of the same architecture and it just works.

Kernel & Runtime

proc-trace-dns intercepts DNS at the system level. eBPF mode requires kernel 4.4+ with BPF support; raw socket mode works on any kernel 2.6+.

RequirementDetailsStatus
Linux kernel 4.4+ Required for eBPF mode (CONFIG_BPF=y, default on Ubuntu 16.04+, Fedora 23+, RHEL 8+). Raw socket fallback works on older kernels. ✓ universal
CAP_NET_RAW Required to observe DNS packets. Run as root or grant capability to the binary with setcap. ✓ root / setcap
Go 1.22+ Only needed for 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 build script.
  2. Mark build.sh executable and run it
    The script handles everything: image pull, cross-compilation, and output.
  3. Find your binary in ./dist/
    Copy the right arch binary to /usr/local/bin/.
build.sh — docker cross-compile
# Clone
 git clone https://github.com/binRick/proc-trace-dns.git
 cd proc-trace-dns

# Build
 chmod +x build.sh
 ./build.sh
Building proc-trace-dns v0.1.0 ...
  → linux/amd64
  → linux/arm64
Done. Binaries in ./dist/:
  proc-trace-dns-linux-amd64  (5.1 MB)
  proc-trace-dns-linux-arm64  (4.8 MB)

# Install
 sudo cp dist/proc-trace-dns-linux-amd64 /usr/local/bin/proc-trace-dns
 proc-trace-dns --version
proc-trace-dns v0.1.0

From source with local Go

If you already have Go installed, this is the fastest path. The resulting binary is dynamically linked but works fine for development and local use.

go build — quick
 git clone https://github.com/binRick/proc-trace-dns.git
 cd proc-trace-dns
 go build -o proc-trace-dns .
 sudo ./proc-trace-dns
  (watching all DNS queries system-wide...)

Fully static, zero runtime deps

Disabling CGO and stripping debug symbols produces a self-contained binary you can copy anywhere: another machine, a container, a server with no Go install.

go build — static
 CGO_ENABLED=0 go build -ldflags="-s -w" -o proc-trace-dns .

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

# Copy to any amd64 Linux box
 scp proc-trace-dns user@server:/usr/local/bin/

Grant CAP_NET_RAW with setcap

Instead of running as root every time, you can grant only the capability the tool actually needs.

setcap — drop root requirement
# Grant the capability (one-time, as root)
 sudo setcap cap_net_raw+eip /usr/local/bin/proc-trace-dns

# Verify
 getcap /usr/local/bin/proc-trace-dns
/usr/local/bin/proc-trace-dns cap_net_raw=eip

# Now run as a normal user
 proc-trace-dns -n curl

Confirm the build works

A quick sanity-check before deploying.

smoke test
# Print version
 proc-trace-dns --version
proc-trace-dns v0.1.0

# Print help
 proc-trace-dns -h

# Trace one curl call end-to-end
 sudo proc-trace-dns -n curl -- curl -s https://example.com > /dev/null
12345  curl  A  example.com   93.184.216.34  1.2ms