Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello all, I'm trying to calculate and print out all subnets of prefix length x from a subnet with a prefix length y \. For example: I want to split a /40, say 2001:0DB8::/40 into /56 subnets. I thought about using NetAddr::IP , for example:
use NetAddr::IP; my $sub6 = new NetAddr::IP '2001:db8::/40'; my $i=1; while ($sub6 < $sub6->broadcast) { # should've been <= but it does no +t seem to work if ($i==4722366482869645213696) { # that many addresses in a / +56 print "ip = $sub6\n"; $i=1; } $sub6 ++; $i++; } print "ip = $sub6\n"; # need to print last address
the above probably works but seems so inefficient and terribly slow. Any ideas would be greatly welcomed!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: efficient IPv6 subnetting
by BrowserUk (Patriarch) on Nov 25, 2015 at 15:46 UTC | |
|
Re: efficient IPv6 subnetting
by stevieb (Canon) on Nov 25, 2015 at 00:37 UTC | |
by stevieb (Canon) on Nov 25, 2015 at 01:26 UTC | |
|
Re: efficient IPv6 subnetting
by stevieb (Canon) on Nov 24, 2015 at 21:38 UTC |