curl lookup time is 5.5 seconds when accessing address in /etc/hosts

0

In my /etc/hosts file I have a custom entry since the name doesn't actually exist like this:

5.5.5.5 someinternalserver.thing.net #thats a fake IP for this post

Using curl like so:

curl -o /dev/null http://someinternalserver.thing.net/img/panda.jpg

Takes 6 seconds. 5.5 for DNS lookup and 0.5 for actually downloading the file.

If I force curl to use IPV4 it works without delay

curl -4 -o /dev/null http://someinternalserver.thing.net/img/panda.jpg

This was working perfectly fine until this morning. How do I even go about troubleshooting this?

I cannot add an IPV6 address to /etc/hosts as the internal network here doesn't support it. Forcing curl to IPV4 works fine if I want to use terminal but the real problem is with scripts/apps that utilize curl.

Sean256

Posted 2016-05-05T01:37:44.653

Reputation: 550

Which version of OS X? What's your /etc/resolv.conf set to? What IPv6 configuration is your Mac using? – Spiff – 2016-05-05T04:32:15.543

Answers

0

Your DNS resolver (library) is probably doing parallel requests for IPv4 and IPv6. It waits for both requests to finish until returning a response.

The IPv6 query times out after 5 seconds, and then curl gets the IP address from the lib.

See https://askubuntu.com/a/32312/15110 which recommends putting the following into /etc/resolv.conf:

options single-request

cweiske

Posted 2016-05-05T01:37:44.653

Reputation: 1 010