1

So I have been using the following method lately proposed here: Return IPv6 address Python from domain name in order to get IPv6 addresses of some sites:

def getIPv6Addr(input):
    socket.getaddrinfo(input, None, socket.AF_INET6)

The method was working a couple of days ago nevertheless, when I use it now it gives me None as a response. For example print getIPv6Addr("www.google.com") returns None whereas it should return 2a00:1450:400c:c01::69.

Can anyone tell me why this is happening?

Community
  • 1
  • 1
Martin
  • 79
  • 3
  • 12
  • `socket.getaddrinfo("google.com", None, socket.AF_INET6)` returns `[(10, 1, 6, '', ('2607:f8b0:4004:801::1001', 0, 0, 0)), (10, 2, 17, '', ('2607:f8b0:4004:801::1001', 0, 0, 0)), (10, 3, 0, '', ('2607:f8b0:4004:801::1001', 0, 0, 0))]` for me. Perhaps your problem is elsewhere. – Nolen Royalty Jul 22 '13 at 21:07
  • but where else could the problem be? – Martin Jul 22 '13 at 21:10
  • The problem might be in your DNS resolution infrastructure. On Linux, try "host www.google.com" and look for a line like "www.google.com has IPv6 address 2607:f8b0:400f:800::1010". – Robᵩ Jul 22 '13 at 21:21
  • thing is the method was working yesturday! i dont know what went wrong. im not THAT worried about what comes back but something has to come back from the query because yday i made a list using that method of ipv6 enabled servers. – Martin Jul 22 '13 at 21:24
  • I think this is more a misconfiguration in your operating system or DNS resolvers than a programming error. – Sander Steffann Jul 22 '13 at 21:29
  • hmmm what sort of misconfiguration tho? i have no idea.. – Martin Jul 22 '13 at 22:28

1 Answers1

2

It looks like you constructed the call to getaddrinfo correctly, but you didn't return the value.

Try this:

def getIPv6Addr(input):
    return socket.getaddrinfo(input, None, socket.AF_INET6)
Michael Hampton
  • 9,737
  • 4
  • 55
  • 96