iprange is a fast command-line tool for reading, normalizing, comparing, and exporting IPv4 address sets.
It understands single IPs, CIDRs, netmasks, numeric IPs, ranges, and hostnames. You can use it to merge blocklists, compute intersections or exclusions, generate data for ipset restore, or compare multiple IP sets as CSV.
iprange accepts one entry per line and can mix formats in the same input:
- single IPs
1.2.3.4
- CIDRs
1.2.3.0/24
- dotted netmasks
1.2.3.0/255.255.255.0
- abbreviated IPs
10.110.1.1
- IP ranges
1.2.3.0 - 1.2.3.255
- ranges where both sides use CIDR or netmask notation
- numeric IPs
- hostnames
Important input behavior:
- Hostnames are resolved in parallel.
- Comments after
#or;are ignored. - Parsing uses
inet_aton(), so octal and hex forms are accepted too. - Inputs can come from
stdin, files, file lists, or directory expansion.
union/merge/optimize- merge all inputs and print the normalized result
common- print the intersection of all inputs
exclude-next- merge the inputs before the option, then remove anything matched by the inputs after it
ipset-reduce- trade a controlled increase in entries for fewer prefixes
compare- compare all inputs against all other inputs and print CSV
compare-first- compare the first input against every other input
compare-next- compare one group of inputs against the next group
count-unique- merge all inputs and print CSV counts
count-unique-all- print one CSV count line per input
Merge and normalize:
iprange blocklist-a.txt blocklist-b.txtFind common IPs:
iprange --common blocklist-a.txt blocklist-b.txtExclude one set from another:
iprange allow.txt --exclude-next deny.txtCount unique entries:
iprange -C blocklist-a.txt blocklist-b.txt
iprange --count-unique-all --header blocklist-a.txt blocklist-b.txtGenerate single-IP output:
iprange -1 hosts.txtGenerate binary output for fast round-trips on the same architecture:
iprange --print-binary blocklist.txt > blocklist.bin
iprange blocklist.binGenerate ipset restore-style lines:
iprange --print-prefix 'add myset ' --print-suffix '' blocklist.txtFrom a release tarball:
./configure
make
make installFrom git:
./autogen.sh
./configure
make
make installIf you do not want to build the man page:
./configure --disable-manProject test entry points:
./run-tests.sh- CLI regression suite
./run-build-tests.sh- build and layout regressions
./run-sanitizer-tests.sh- ASAN/UBSAN/TSAN coverage
make check- normal build-integrated test path
make check-sanitizers- sanitizer-integrated test path
src/- C sources and headers
packaging/- packaging helpers, spec template, ebuild, and release tooling
tests.d/- CLI regression tests
tests.build.d/- build and layout regressions
tests.sanitizers.d/- sanitizer CLI regressions
tests.tsan.d/- TSAN regressions
tests.unit/- unit-style harnesses for internal edge cases
For the full option list:
iprange --helpThe project wiki content that originally documented the feature set is now folded into this README so the repository landing page explains the tool directly.