IPAddress: new IP manipulation library

Hi,

I’ve released IPAddress 0.5.0, first release to be public available.

IPAddress is an IPv4 and IPv6 addresses manipulation library, designed
to be easy to use. It is probably the most complete and powerful IP
manipulation library available today.

Some key features:

  • support for IPv4, IPv6 and IPv4-IPv6 mapped addresses;
  • easy handling of networks, broadcasts, prefixes;
  • classless and classful (legacy) implementation;
  • full set of conversion methods (bit strings, hex, unsigned
    integers);
  • network design features: subnetting, summarization, supernetting;
  • comprehensive documentation;

IPAddress is already available as a gem on rubygems.org:

http://rubygems.org/gems/ipaddress

Migration from IPAddr should be seamlessly and pretty straightforward.
We’ll soon write a tutorial on how to perform such migration.

Regards,
Marco

On Mon, May 24, 2010 at 6:03 PM, bluemonk [email protected] wrote:

I’ve released IPAddress 0.5.0, first release to be public available.
GitHub - ipaddress-gem/ipaddress: A library to handle IPv4 and IPv6 addresses in a modern and productive way.

heheh, very nice net tool gem.
thanks -botp

On Mon, May 24, 2010 at 07:03:55PM +0900, bluemonk wrote:

Some key features:

ipaddress | RubyGems.org | your community gem host

Migration from IPAddr should be seamlessly and pretty straightforward.
We’ll soon write a tutorial on how to perform such migration.

Agreed, this is a very nice addition, thank you.

-jeremy

Without having looked at your library, does it support IP ranges (i.e.
blocks of IP addresses that are contiguous but do not necessarily
exactly match a subnet boundary)? Perhaps as a separate class?

Can one do this?

ip = IPAddress.new(“10.0.0.1”) ## No prefix specified… will it
assume /32 IPv4 host prefix?

Also, are there methods to determine if a network (or range, if
supported) contains another IP, network, or range? Something like:

ip = IPAddress.new(“10.0.0.1/32”)
net = IPAddress.new(“10.0.0.0/24”)
puts “IP is contained by network” if net.contains?(ip) || ip.is_in?(net)

Wondering,
Aaron out.

On Jun 7, 2010, at 4:26 PM, Aaron D. Gifford wrote:

supported) contains another IP, network, or range? Something like:

ip = IPAddress.new(“10.0.0.1/32”)
net = IPAddress.new(“10.0.0.0/24”)
puts “IP is contained by network” if net.contains?(ip) || ip.is_in?(net)

Taking two seconds to peruse the (very simple) source would have given
you your answer.

cr

Aaron D. Gifford wrote:

Without having looked at your library, does it support IP ranges (i.e.
blocks of IP addresses that are contiguous but do not necessarily
exactly match a subnet boundary)? Perhaps as a separate class?

…or it could be just a regular Ruby range, like this:

require ‘ip’
=> true

r = IP.new(“10.0.0.6”)…IP.new(“10.0.0.10”)
=> #<IP::V4 10.0.0.6>…#<IP::V4 10.0.0.10>

r.each { |x| p x }
#<IP::V4 10.0.0.6>
#<IP::V4 10.0.0.7>
#<IP::V4 10.0.0.8>
#<IP::V4 10.0.0.9>
#<IP::V4 10.0.0.10>
=> #<IP::V4 10.0.0.6>…#<IP::V4 10.0.0.10>

(It’s an interesting idea that perhaps an IP object should be a
start+end range, but then you need a way to show an IP as a string when
it’s not suitable for addr/len form)

On Jun 6, 9:51 pm, Brian C. [email protected] wrote:

BTW, a little while ago I released a small library,GitHub - deploy2/ruby-ip: IP address manipulation library
and it seems we’ve had some similar ideas (such as separate subclasses
for v4 and v6). I meant to add things like IP#each but never got around
to it :slight_smile:

Hi Brian

I wasn’t aware of your library when I started writing mine. I’m not a
fan of duplicating efforts, pity we didn’t see each other :slight_smile:
Very nice job BTW

Regards,
Marco

On Jun 7, 11:26 pm, “Aaron D. Gifford” [email protected] wrote:

Without having looked at your library, does it support IP ranges (i.e.
blocks of IP addresses that are contiguous but do not necessarily
exactly match a subnet boundary)? Perhaps as a separate class?

Not yet, I plan to introduce ranges in 0.7.0, I’m still working on a
meaningful notation.

Can one do this?

ip = IPAddress.new(“10.0.0.1”) ## No prefix specified… will it
assume /32 IPv4 host prefix?

No, it will assume the classful subnet mask (/8 in this case)

http://marcoceresa.com/ipaddress/classes/IPAddress/IPv4.html#M000008

However this behaviour is currently under discussion, as it is one
major break in respect to IPAddr (the other being #to_s). It may
change in the future.

Also, are there methods to determine if a network (or range, if
supported) contains another IP, network, or range? Something like:

ip = IPAddress.new(“10.0.0.1/32”)
net = IPAddress.new(“10.0.0.0/24”)
puts “IP is contained by network” if net.contains?(ip) || ip.is_in?(net)

Yes:

http://marcoceresa.com/ipaddress/classes/IPAddress/IPv4.html#M000034

Regards,
Marco

bluemonk wrote:

IPAddress is an IPv4 and IPv6 addresses manipulation library, designed
to be easy to use. It is probably the most complete and powerful IP
manipulation library available today.

Looks like you’ve done a good job.

BTW, a little while ago I released a small library,

and it seems we’ve had some similar ideas (such as separate subclasses
for v4 and v6). I meant to add things like IP#each but never got around
to it :slight_smile:

Regards,

Brian.