Hi,
I'm looking for any tool or a way I could specify a CIDR and the prefixes
that are being used within this CIDR and the tool show me all free
supernets.
Example:
192.168.0.0/24 - CIDR
Used subnet's:
192.168.0.1/32
192.168.0.8/27
192.168.0.64/26
192.168.0.68/32
192.168.0.96/29
Tool Result => Free Subnet's:
192.168.0.2/31
192.168.0.4/30
192.168.0.32/27
192.168.0.128/25
Regards,
John
most reasonable ipam tools will track or express unallocated vs
allocated space.
netdot has a lovely address-space container/block view for managing free
vs allocated space
joel
I've used subnetsmngr for this in the past. Proper usage of it thru the UI forces you to fully allocate (as compared to sparse allocating) your subnets, basically the same way subetting is taught in base level networking certifications. This makes finding the un-used subnets very easy.
http://sourceforge.net/p/subnetsmngr/wiki/Home/
NIPAP allows you to do the same as well, but will let subnets be sparse allocated, so you won't necessarily have pre-created them waiting to be used later on.
http://spritelink.github.io/NIPAP/
NIPAP also has a nice CLI interface.
Both are also open source, full v4/v6.
Theo
Attached is a perl script I wrote for a coworker that you can tweak as
you'd like. It's designed to log into a router and dump the route table(s)
and find used/unused subnets in a given supernet. Available routes are
green and used routes are red. Yellow routes are routes where we have
route and a more specific route so the first route is probably an aggregate
and there _may_ be open space available.
John,
Without going through the hassle of installing a full-blown IPAM solution you could use Python's netaddr library to accomplish what you are asking:
from netaddr import *
cidr = IPSet(['192.168.0.0/24'])
used = IPSet(['192.168.0.1','192.168.0.8/29','192.168.0.64/26'])
cidr ^ used
IPSet(['192.168.0.0/32', '192.168.0.2/31', '192.168.0.4/30', '192.168.0.16/28', '192.168.0.32/27', '192.168.0.128/25'])
Jeremiah Millay
Senior Network Engineer
Vermont Telephone Co., Inc.
354 River Street
Springfield, VT 05156
For the weekend exercise I wrote a small script that does this. You can
find it at http://pastebin.com/i0D54Lsq
Usage:
cat input.txt | ./subnet.sh
The input.txt file contains your input such as:
Baldurs-MBP-2:~ baldur$ cat /tmp/x
add 192.168.0.0/24
remove 192.168.0.1/32
remove 192.168.0.8/27
remove 192.168.0.64/26
remove 192.168.0.68/32
remove 192.168.0.96/29
Baldurs-MBP-2:~ baldur$ cat /tmp/x | ./subnet.sh
192.168.0.32/27
192.168.0.128/25
Note this was not your expected output, but that is because your example is
defective. To get your expected output we can modify the input such as:
Baldurs-MBP-2:~ baldur$ cat /tmp/x
add 192.168.0.0/24
remove 192.168.0.0/31
remove 192.168.0.3/32
remove 192.168.0.8/29
remove 192.168.0.16/28
remove 192.168.0.64/26
remove 192.168.0.68/32
remove 192.168.0.96/29
Baldurs-MBP-2:~ baldur$ cat /tmp/x | ./subnet.sh
192.168.0.2/32
192.168.0.4/30
192.168.0.32/27
192.168.0.128/25
You can have multiple add lines and add/remove lines in any order.
Regards,
Baldur
Learned that attachments do make it to the list. Here's a link:
http://pastebin.com/tMdcfvji
The results appear to be missing 192.168.0.0/32.
Is this intended behavior?
192.168.0.8/27 is not a valid CIDR — It actually represents an address within 192.168.0.0/27, so actually, rather than missing 192.168.0.0/32, one could argue that there are erroneous reports for 192.168.0.2/31, 192.168.0.4/30 being available.
192.168.0.64/26 encompasses 192.168.0.68/32 and 192.168.0.96/29, so there’s also an allocation conflict potential there.
I thought I understood what you were looking for from your question, but your example creates significant confusion.
Owen