Download the PHP package andrewandante/submuncher without Composer
On this page you can find all versions of the php package andrewandante/submuncher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andrewandante/submuncher
More information about andrewandante/submuncher
Files in andrewandante/submuncher
Package submuncher
Short Description Tool for consolidating subnets
License MIT
Informations about the package submuncher
SubMuncher
Handy tool for consolidating subnets into as few subnets as possible
Installation
composer require andrewandante/submuncher
Using it
The most basic usage is to pass an array of IPv4 addresses into AndrewAndante\SubMuncher\SubMuncher::consolidate()
The most useful usage is to pass an array of CIDRs into AndrewAndante\SubMuncher\SubMuncher::consolidate_subnets()
There are also a bunch of helper IP utility functions in the Util
classe should you need to do some tweaking.
You can also pass a second parameter that limits the number of rules returned. This invokes some magic to combine some subnets in a way that introduces the least number of additional IP addresses into the range as possible.
For example, to reduce your list of subnets down to 25 total rules, try AndrewAndante\SubMuncher\SubMuncher::consolidate_subnets($cidrsArray, 25);
Debugging
There are verbose methods which will give you the initial list of IPs covered by your CIDRs, and the ultimate list covered. That will give you the opportunity to compare, so you can see what additional IPs have been introduced. This is in case you are using them for a whitelist or something that requires exact knowledge of the IPs.
Warning
This is significantly slower when calculating subnets, as it expands out all the individual IPs in the subnet, rather than just using the first and last IP
Limitations
Only tested on IPv4 at present.