nbcalc

NAME
SYNOPSIS
DESCRIPTION
USAGE
EXAMPLES
AUTHOR

NAME

nbcalc - perform calculations on IP address ranges

SYNOPSIS

nbcalc IP - IP
nbcalc
IPRange [[+|-] [-]IPRange ...]

DESCRIPTION

Nbcalc determines the set of all IP addresses included in the IP address range specifications given on its command line, and then outputs the set as one or more CIDR netblocks.
If invoked with exactly three arguments, of which the middle one is a dash, nbcalc prints out the IP address range from the first IP address to the second IP address as CIDR netblocks. This is convenient for converting WHOIS lookups (almost always in this form) into CIDR netblocks.

USAGE

IP address ranges may be specified in three forms: single IP addresses, CIDR netblocks (zero octets may be omitted, eg you may write 127/8 for 127.0.0.0/8), or an arbitrarily large range written LOW-HIGH. Any CIDR netblocks given must be proper ones, where the IP address is the lowest bound of the range (eg, 127.0.0.0/24 is a proper CIDR, but 127.0.0.1/24 is not, because 127.0.0.1 is not the start of the /24 that includes it).
Nbcalc normally adds all of its IP address ranges together to form the set. A lone - as an argument causes nbcalc to begin subtracting subsequence IP address ranges from the set; a + switches nbcalc back to adding them in. If an argument is prefixed with a -, that argument is always subtracted from the set.

EXAMPLES

$ nbcalc 127.0.0.0 - 127.31.255.255
127.0.0.0/11
$ nbcalc 127.0.0.0/24 127.0.1.0/24
127.0.0.0/23
$ nbcalc 127.0.0.0/22 - 127.0.0.0/24 127.0.2.0/24 + 127.0.0.0/23
127.0.0.0/23
127.0.3.0/24

AUTHOR

Chris Siebenmann