Print/list/check address blocks, matching a CIDR network prefix, from command line?

1

I am not much of a network person, but I understand that (IPv4) addresses can be written in a format like 127.0.0.1/16. I tried reading through Wikipedia's IPv4 subnetting reference, Subnetwork and CIDR_notation - but it's way too much detail than I need.

I, essentially, don't need to understand CIDR notation for now - all I want is a command line tool, where I can type something like 127.0.0.1/16, and see what addresses it matches.

Is there a command line tool I can use for the purpose?

sdaau

Posted 2013-04-22T18:50:54.030

Reputation: 3 758

Answers

1

Try out ipcal available on, and from this webpage: http://www.jodies.de/ipcalc

Squeezy

Posted 2013-04-22T18:50:54.030

Reputation: 5 930

Many thanks for that, @Squeezy - ipcalc looks like a fine Perl script, latest version currently seems to be ipcalc-0.41; cheers!

– sdaau – 2014-01-30T10:07:59.417

1Mate, where have you been the last 10 months? :D – Squeezy – 2014-02-03T20:13:26.270

0

Well, searching through the Net, I accidentally found this:

It is a Python script, so I simply renamed it when I downloaded it, and used it like so:

$ wget http://brandon.sternefamily.net/files/cidr.txt -O cidr.py
$ python cidr.py 127.0.0.1/30
127.0.0.0
127.0.0.1
127.0.0.2
127.0.0.3

Would love to hear if there's anything else in existence that works like this...

Well, hope this helps someone,
Cheers!


EDIT: original link seems to be gone, here is archive: http://web.archive.org/web/20100307140430/http://brandon.sternefamily.net/files/cidr.txt

sdaau

Posted 2013-04-22T18:50:54.030

Reputation: 3 758

0

you need prips:

$ prips 127.0.0.0/16

be careful it's going to print 65536 lines:

$ prips 127.0.0.0/16 | wc -l
65536

BTW: 127.0.0.1 is an incorrect input, as it is a host in a range, but you must specify a network. Use ipcalc to get a network:

$ ipcalc -b 127.0.0.1/16

Address: 127.0.0.1
Netmask: 255.255.0.0 = 16
Wildcard: 0.0.255.255
=> Network: 127.0.0.0/16
HostMin: 127.0.0.1
HostMax: 127.0.255.254
Broadcast: 127.0.255.255
Hosts/Net: 65534 Class A, Loopback

nefski

Posted 2013-04-22T18:50:54.030

Reputation: 101