Name resolution problems with IPv6?
I am in over my head trying to troubleshoot a network problem and I
would greatly appreciate any help.
I have a Python app that has connected perfectly well via HTTP to
thousands of servers but has encountered one (floridasbestmortgages.com)
where the connection consistently fails after a long delay. I've traced
the delay and error as far as a call to getaddrinfo(), and I've noted
three things that may be helpful in diagnosis:
1) My Python is compiled with IPv6 support
2) When IPv6 support is enabled at compile time, Python's getaddrinfo()
code makes this call:
getipnodebyname(hostname, AF_INET6, AI_ADDRCONFIG|AI_ALL|AI_V4MAPPED,
whereas when it is disabled the Python library calls this:
3) Calling gethostbyname("floridasbestmortgages.com") directly (it's
exposed by Python's socket library) always returns the correct IP
Experiments on several machines (FeeeBSD, RHEL and OS X) in different
locations give fairly consistent results: if I tell Python to use IPv4
(AF_INET), getaddrinfo() returns a correct result almost instantly. If I
tell it to use IPv6 (AF_INET6), I get a delay (consistent over time but
varies from machine to machine) and then an error. If I pass AF_UNSPEC,
I first get the delay and then a correct result, so I guess Python falls
back to IPv4 after IPv6 fails.
I have a strong hunch that the problem is related to IPv4/v6 address
resolution via getaddrinfo() as described in section 3 of this document:
Naturally, the v6 delay is worst (~ 2 minutes) on my most important
machine; it averages about 10 seconds on the other machines. Since the
delay varies depending on the machine, I'm guessing that it is the name
resolution process that each machine follows which causes the delay. I
don't know how to expose that process and that's where I could really
use some help. How do I find out why my connection takes ~2 minutes to
time out? If someone's DNS is broken, I'd like to resolve the problem
there rather than by disabling IPv6 support on my end.
I could duck this whole problem by recompiling Python without IPv6
support, but that seems like using dynamite to kill a mosquito.
In case anyone is interested in the Python code I've been using to test
with, here's the crucial bits to paste into an interactive session:
socket.getaddrinfo("floridasbestmortgages.com", "http", socket.AF_INET)
socket.getaddrinfo("floridasbestmortgages.com", "http", socket.AF_INET6)
socket.getaddrinfo("floridasbestmortgages.com", "http", socket.AF_UNSPEC)
Thanks very much in advance for any help.
email: first name @ last name.com