in reply to Re: NetAddr::IP Automated Subnet Allocation
in thread NetAddr::IP Automated Subnet Allocation

Your solution works, but I need to add 1 to the address of the broadcast address, so I can begin the next sub-network. Your solution returns the numberic() of the current address field, which is the base network address.
amt
  • Comment on Re^2: NetAddr::IP Automated Subnet Allocation

Replies are listed 'Best First'.
Re^3: NetAddr::IP Automated Subnet Allocation
by ikegami (Patriarch) on Sep 03, 2004 at 15:18 UTC
    Your solution returns the numberic() of the current address field, which is the base network address.

    Not so. Did you type in $net_addr where you should have typed $net_broadcast?

    use NetAddr::IP (); my $net_addr = NetAddr::IP->new('192.168.1.0/29'); my $net_broadcast = $net_addr->broadcast(); my $net_newaddr; { my ($addr, $mask) = $net_broadcast->numeric(); $net_newaddr = NetAddr::IP->new($addr+1, $mask); } print("$net_addr\n"); # prints 192.168.1.0/29 print("$net_broadcast\n"); # prints 192.168.1.7/29 print("$net_newaddr\n"); # prints 192.168.1.8/29