divide by 64 error

11 views
Skip to first unread message

marc williams

unread,
Jul 13, 2011, 6:28:32 AM7/13/11
to Ruby IPAddress
I cant do:


ip = IPAddress.parse "1.1.1.0/24"

subnets = ip / 64
puts subnets


spits out an error message:


gem/ruby/1.8/gems/ipaddress-0.8.0/lib/ipaddress/ipv4.rb:684:in
`subnet': New prefix must be between 24 and 32 (ArgumentError)
from /Users/.gem/ruby/1.8/gems/ipaddress-0.8.0/lib/ipaddress/ipv4.rb:
622:in `/'
from ./ip.rb:7

I am trying to divide a /24 address space into /30's


Marco Ceresa

unread,
Aug 8, 2011, 8:23:11 AM8/8/11
to ruby-ip...@googlegroups.com
On Wed, Jul 13, 2011 at 12:28 PM, marc williams
<marcwil...@gmail.com> wrote:
> I cant do:
>
> ip = IPAddress.parse "1.1.1.0/24"
>
> subnets = ip / 64
> puts subnets
>
> spits out an error message:
>
> gem/ruby/1.8/gems/ipaddress-0.8.0/lib/ipaddress/ipv4.rb:684:in
> `subnet': New prefix must be between 24 and 32 (ArgumentError)
>        from /Users/.gem/ruby/1.8/gems/ipaddress-0.8.0/lib/ipaddress/ipv4.rb:
> 622:in `/'
>        from ./ip.rb:7

Hello Marc,
thanks for pointing out this issue. I will investigate it further.
Would you care to open an issue on Github on this one?

> I am trying to divide a /24 address space into /30's

In the meantime you can use IPv4#subnet which works fine

subnets = ip.subnet(30)

Regards,
Marco

Reply all
Reply to author
Forward
0 new messages