Subnet calculator - command line tool to calculate from a given IP address possible CIDR network/mask and address ranges

Usage: subnet-calc IP-address/[number-of-bits]
or:    subnet-calc IP-address [number-of-bits]
or:    subnet-calc IP-address/[number-of-bits] -s
e.g. 
subnet-calc 192.168.0.1 24
will produce:
192.168.0.0/24 = 192.168.0.1 - 192.168.0.255
and
subnet-calc 192.168.0.1
will produce:
192.0.0.0/8 = 192.0.0.0 - 192.255.255.255
192.128.0.0/9 = 192.128.0.0 - 192.255.255.255
192.128.0.0/10 = 192.128.0.0 - 192.191.255.255
192.160.0.0/11 = 192.160.0.0 - 192.191.255.255
192.160.0.0/12 = 192.160.0.0 - 192.175.255.255
192.168.0.0/13 = 192.168.0.0 - 192.175.255.255
192.168.0.0/14 = 192.168.0.0 - 192.171.255.255
192.168.0.0/15 = 192.168.0.0 - 192.169.255.255
192.168.0.0/16 = 192.168.0.0 - 192.168.255.255
192.168.0.0/17 = 192.168.0.0 - 192.168.127.255
192.168.0.0/18 = 192.168.0.0 - 192.168.63.255
192.168.0.0/19 = 192.168.0.0 - 192.168.31.255
192.168.0.0/20 = 192.168.0.0 - 192.168.15.255
192.168.0.0/21 = 192.168.0.0 - 192.168.7.255
192.168.0.0/22 = 192.168.0.0 - 192.168.3.255
192.168.0.0/23 = 192.168.0.0 - 192.168.1.255
192.168.0.0/24 = 192.168.0.0 - 192.168.0.255
192.168.0.0/25 = 192.168.0.0 - 192.168.0.127
192.168.0.0/26 = 192.168.0.0 - 192.168.0.63
192.168.0.0/27 = 192.168.0.0 - 192.168.0.31
192.168.0.0/28 = 192.168.0.0 - 192.168.0.15
192.168.0.0/29 = 192.168.0.0 - 192.168.0.7
192.168.0.0/30 = 192.168.0.0 - 192.168.0.3
It skips masks 1-7 and 31-32 bits-long as these are less useful.

and 
subnet-calc 192.168.0.1/18 -s
will produce:
192.168.0-63
but
subnet-calc 192.168.0.1/24 -s
will produce:
192.168.0.
0-255 at the end is skipped

This is free software. Enjoy. I hope you will find it useful.

Send bug reports/comments to jacek@jacek-dom.net
