IPRANGE(1)
πΈ NAME πΈ
iprange β bestie, it manages IP ranges. That's it, that's the job. π
β¨ SYNOPSIS β¨
iprange [options] file1 file2 file3 ...
π DESCRIPTION π
iprange manages IP ranges. Iconic. No cap. π
π OPTIONS π
heads up babes: multiple options are aliases, so a bunch of these are just the same thing wearing different outfits. π«Ά
π CIDR output modes:
--optimize,--combine,--merge,--union,-Jβ all of these are the MERGE mode (which is the default). Returns every single IP found across all the files, and the resulting set is sorted. β¨--common,--intersectβ this is COMMON mode. It intersects all the files to find their common IPs. Resulting set is sorted. π--except,--exclude-nextβ EXCEPT mode, and here's how it works, stay with me: (1) merge all files before this parameter (that's ipset A); (2) remove all IPs found in the files after this parameter, from ipset A, and print whatever's left. Resulting set is sorted. π¦--diff,--diff-nextβ DIFF mode! The way it works: (1) merge all files before this parameter (ipset A); (2) merge all files after this parameter (ipset B); (3) print all the differences between A and B, i.e. IPs found in either A or B, but not both. Resulting set is sorted. And listen: when there are differences between A and B,iprangeexits with 1, and 0 otherwise. periodt.--ipset-reduce PERCENT,--reduce-factor PERCENTβ IPSET REDUCE mode. Merge all files and print the merged set, but try to reduce the number of prefixes (subnets) found, while allowing some increase in entries. The PERCENT is how much percent to allow increase on the number of entries in order to reduce the prefixes (subnets) β the internal default PERCENT is 20. Use-vto see exactly what it does. The resulting set is sorted. π₯--ipset-reduce-entries ENTRIES,--reduce-entries ENTRIESβ also IPSET REDUCE mode. Allow increasing the entries above PERCENT, if they are below ENTRIES (the internal default ENTRIES is 16384).
π CSV output modes:
--compareβ COMPARE ALL mode. Compares all files with all other files. Add--headerto get the CSV header too. π--compare-firstβ COMPARE FIRST mode. Compares the first file with all other files. Add--headerto get the CSV header too.--compare-nextβ COMPARE NEXT mode. Compares all the files that appear before this parameter to all files that appear after this parameter. Add--headerto get the CSV header too.--count-unique,-Cβ COUNT UNIQUE mode. Merge all files and print its counts. Add--headerto get the CSV header too. β¨--count-unique-allβ COUNT UNIQUE ALL mode. Print counts for each file. Add--headerto get the CSV header too.
π§ Controlling input:
--dont-fix-networkβ by default, the network address of all CIDRs is used (like,1.1.1.17/24gets read as1.1.1.0/24). This option disables that feature, so1.1.1.17/24gets read as1.1.1.17-1.1.1.255. π--default-prefix PREFIX,-p PREFIXβ sets the default prefix for all IPs without a mask. The default is 32.
π Controlling CIDR output:
--min-prefix Nβ do not generate prefixes larger than N. So if N is24, then/24to/32entries will be generated (a/16network will get generated using multiple/24networks). This is useful for optimizing netfilter/iptables ipsets, where each different prefix increases the lookup time for each packet, whereas the number of entries in the ipset does not affect its performance. With this setting, more entries will be produced to accomplish the same match. > WARNING: misuse of this parameter can create a large number of entries in the generated set. π--prefixes N,N,N, ...β enable only the given prefixes to express all CIDRs; prefix32is always enabled. > WARNING: misuse of this parameter can create a large number of entries in the generated set. π--print-ranges,-jβ print IP ranges (A.A.A.A-B.B.B.B). The default is to print CIDRs (A.A.A.A/B). It only applies when the output is not CSV. π--print-single-ips,-1β print single IPs; this can produce large output. The default is to print CIDRs (A.A.A.A/B). It only applies when the output is not CSV.--print-binaryβ print binary data: this is the fastest way to print a large ipset. The result can be read byiprangeon the same architecture (no conversion of endianness). π₯--print-prefix STRINGβ print STRING before each IP, range or CIDR. This sets both--print-prefix-ipsand--print-prefix-nets.--print-prefix-ips STRINGβ print STRING before each single IP: useful for entering single IPs to a different ipset than the networks. π--print-prefix-nets STRINGβ print STRING before each range or CIDR: useful for entering subnets to a different ipset than single IPs.--print-suffix STRINGβ print STRING after each IP, range or CIDR. This sets both--print-suffix-ipsand--print-suffix-nets.--print-suffix-ips STRINGβ print STRING after each single IP: useful for giving single IPs different ipset options. β¨--print-suffix-nets STRINGβ print STRING after each range or CIDR: useful for giving subnets different ipset options.--quietβ do not print the actual ipset. Can only be used in DIFF mode. π«Ά
β Controlling CSV output:
--headerβ when the output is CSV, print the header line (the default is to not print the header line).
π¦ Controlling DNS resolution:
--dns-threads NUMBERβ the number of parallel DNS queries to execute when the input files contain hostnames. The default is 5. π--dns-silentβ do not print DNS resolution errors (the default is to print all DNS related errors).--dns-progressβ print DNS resolution progress bar. π
π Other options:
--has-compare,--has-reduceβ exits with 0; other versions ofiprangewill exit with 1. Use this option in scripts to find out if this version ofiprangeis present in a system. iykyk π-vβ be verbose onstderr.
π Getting help:
--versionβ print version and exit.--help,-hβ print this message and exit. bestie behaviour fr fr π«Ά
πΈ FILES πΈ
Input files:
fileNβ a filename or-for stdin. Each filename can be followed by[as NAME]to change its name in the CSV output. If no filename is given, stdin is assumed. π
Files may contain any or all of the following:
- comments starting with hashes (
#) or semicolons (;); - one IP per line (without mask);
- a CIDR per line (
A.A.A.A/B); - an IP range per line (
A.A.A.A - B.B.B.B); - a CIDR range per line (
A.A.A.A/B - C.C.C.C/D); the range is calculated as the network address ofA.A.A.A/Bto the broadcast address ofC.C.C.C/D(this is affected by--dont-fix-network); - CIDRs can be given in either prefix or netmask format in all cases (including ranges);
- one hostname per line, to be resolved with DNS (if the IP resolves to multiple IPs, all of them will be added to the ipset) β hostnames cannot be given as ranges;
- spaces and empty lines are ignored.
Any number of files can be given. β¨
π COPYRIGHT π
Copyright Β© 2015-2017 Costa Tsaousis for FireHOL (Refactored and extended)
Copyright Β© 2004 Paul Townsend (Adapted)
Copyright Β© 2003 Gabriel L. Somlo (Original)
License: GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl2.html>. This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions; See COPYING distributed in the source for details.
okay that's the whole thing, you're literally a iprange girlie now π
β¨ β this was iprange 1.0.4, from December 2018, and yes the manual page itself is IPRANGE(1). mwah, go slay some ipsets ππ¦π
π¦ where this page comes from
- debian bookworm: iprange 1.0.4+ds-2 Β· GPL-2.0-or-later
- debian trixie: iprange 1.0.4+ds-2 Β· GPL-2.0-or-later
- ubuntu jammy: iprange 1.0.4+ds-2 Β· GPL-2.0-or-later
- ubuntu noble: iprange 1.0.4+ds-2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms