Divide CIDR into smaller chunks of spefied length

I would like to divide up a CIDR block into smaller subnets.

For example if the CIDR block is 10.0.0.0/4, then I would like to spilt is up into multiple /8s. Here prefix length of /8 is a user input.

This needs to be similar to subnet method of netaddr module in Python

Do you mean this method?

https://netaddr.readthedocs.io/en/latest/api.html#netaddr.IPNetwork.subnet

Yes.

For the record: the implementation of this method.

Thanks. Is there a Go equivalent of this available?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.