1.3 KiB
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_rawon Linux:sudo setcap cap_net_raw+ep /path/to/ipgrep
-l/--lookupcache:- defaults to the OS cache dir (override with
--cache-path) - control size and freshness with
--cache-max-entriesand--cache-ttl
- defaults to the OS cache dir (override with
- MAC
-r/--resolveand MAC-p/--pingableare best-effort and rely on the local neighbor/ARP table:- Linux:
/proc/net/arp - Other OSes: currently unsupported without external tooling
- Linux: