Bug#851388: IPv6 resolving broken

Niko Tyni ntyni at debian.org
Sun Jan 15 14:20:27 UTC 2017


On Sat, Jan 14, 2017 at 02:25:51PM +0000, Mike Gabriel wrote:
> Package: libnetaddr-ip-perl
> Severity: important
> Version: 4.079+dfsg-1
> 
> Resolving DNS names to IPv6 addresses with NetAddr::IP->new6($hostname)
> fails and results in some IPv4'ish address with IPv6 syntax.

> 0:0:0:0:0:0:808:808/128 <- WTF???
> 8.8.8.8/32

[ The first address is in the "IPv4-Compatible IPv6 Address" format
  (nowadays deprecated in favour of the "IPv4-Mapped IPv6 Address"
  format), see https://tools.ietf.org/html/rfc4291#section-2.5.5 ]

FWIW it looks to me like this is more or less intentional behaviour.

>From the documentation of the new6() method:

  "->new6" and "->new_cis6" mark the address as being in ipV6
   address space even if the format would suggest otherwise.

  i.e.  ->new6('1.2.3.4') will result in ::102:304

  [...]
  
  $addr can be any of the following and possibly more...
  
  [..]
  
  Fully Qualified Domain Name which returns an ipV4 address or an ipV6
  address, embodied in that order.

This seems to match the code as well, see

  http://sources.debian.net/src/libnetaddr-ip-perl/4.079%2Bdfsg-1/Lite/Lite.pm/#L1023

So it looks for an IPv4 address first as documented, and then makes an
IPv6 address out of that, again as documented. Of course, whether this
behaviour is useful/expected is another matter entirely (and I certainly
agree it's unexpected.)

As noted on IRC, I suspect you're better off doing the resolving step separately.
-- 
Niko Tyni   ntyni at debian.org



More information about the pkg-perl-maintainers mailing list