Wrong IPv4 -> IPv6 mapping

36 views
Skip to first unread message

Shalak

unread,
Jul 6, 2016, 8:31:12 AM7/6/16
to Ruby IPAddress
Hi!

I noticed one issue with this great gem.

IPAddress.parse, when called with "fd00::10.3.0.10/120" returns "::ffff:10.3.0.10" address. The code in ipaddress.rb determines that this should be treated as IPv6::Mapped

when /:.+\./
     
IPAddress::IPv6::Mapped.new(str)


Unfortunately, the correct value should use the "fd00::" prefix and the IPv6 version of it should become "fd00::a03:0:a/120". That's the way the IPv6 is treated in iproute2, ip6tables and pretty much every IPv6 calculator I've seen.


Shalak

unread,
Jul 6, 2016, 8:33:11 AM7/6/16
to Ruby IPAddress
Uh, typo - I mean the final IPv6 should be fd00::a03:a/120

Marco Scholl

unread,
Dec 4, 2017, 10:41:43 AM12/4/17
to Ruby IPAddress
I have the same problem found. I create an issue on GitHub


I hope it will be fixed.

I have create a workaround for me.

    if value =~ /\:/
      converted = value.gsub(/([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/) { |a| IPAddr.new("::#{a}").to_string.slice(-9, 9) }
    else
      converted = value
    end
    IPAddress.parse(converted)


Reply all
Reply to author
Forward
0 new messages