Files
gists/projects/go-tools/goipgrep/README.md
T
tobias 1cbf8afb4a chore: cleanup — untrack binaries, consolidate Go dirs, dedupe tools
- Untrack and delete compiled binaries (tarsum, gosoft.exe, rust uniq/uniq2);
  ignore build outputs (dist/, bin/, *.exe, *.test, .ruff_cache/)
- Merge tools/go/ and projects/go-tools/go/ into projects/go-tools/<name>/
- Fix goipgrep .gitignore: bare 'ipgrep' pattern was ignoring cmd/ipgrep/,
  so the main entrypoint was never tracked; now anchored to /ipgrep
- Archive duplicate implementations to archive/experimental/{rust,go}/
  (uniq, between, tarsum rewrites); canonical versions stay in tools/
- Update README tool catalog to match new layout

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 13:42:45 +02:00

1.3 KiB

ipgrep

Extract IP addresses (and MAC addresses) from text, with optional reachability checks, reverse DNS, and ipinfo.io lookups.

Build

./scripts/build.sh
./dist/ipgrep --help

Install (local)

./scripts/build.sh
sudo install -m 0755 ./dist/ipgrep /usr/local/bin/ipgrep

Usage

# Extract IPv4 addresses from stdin
cat file.txt | ipgrep

# Extract and uniq/sort
ipgrep -u -s file.txt

# Extract MAC addresses
ipgrep -m file.txt

# Reachability filter (auto chooses ICMP if permitted, otherwise TCP probe)
ipgrep -p file.txt

# Reverse DNS (IP only)
ipgrep -r file.txt

# Lookup ipinfo.io and output CSV (default header included)
ipgrep -l --format=csv file.txt

Notes

  • -p/--pingable:
    • --ping-mode=auto (default) uses ICMP echo when raw sockets are available, otherwise falls back to a TCP connect probe.
    • ICMP echo typically requires root or cap_net_raw on Linux:
      • sudo setcap cap_net_raw+ep /path/to/ipgrep
  • -l/--lookup cache:
    • defaults to the OS cache dir (override with --cache-path)
    • control size and freshness with --cache-max-entries and --cache-ttl
  • MAC -r/--resolve and MAC -p/--pingable are best-effort and rely on the local neighbor/ARP table:
    • Linux: /proc/net/arp
    • Other OSes: currently unsupported without external tooling