# ipgrep Extract IP addresses (and MAC addresses) from text, with optional reachability checks, reverse DNS, and ipinfo.io lookups. ## Build ```sh ./scripts/build.sh ./dist/ipgrep --help ``` ## Install (local) ```sh ./scripts/build.sh sudo install -m 0755 ./dist/ipgrep /usr/local/bin/ipgrep ``` ## Usage ```sh # 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