9

From a docker container when I try to curl 'another container name', curl first tries to resolve the name to IPv6. This causes few seconds delay because the web server is not reachable over ipv6.

I removed the link local address on the container interface and also disabled ipv6 on the container's lo and eth0 interface. curl still tries to resolve the name to IPv6 first (unless its forced via curl -4).

This seems wrong. Why does curl try to resolve the name to ipv6 even if ipv6 is disabled ?

3
  • 1
    How is IPv6 disabled, in particular? Otherwise, --ipv4 is a relevant flag to curl in that situation. Commented Feb 24, 2016 at 23:41
  • 2
    I removed v6 addresses from /etc/hosts and did the following.. sysctl -w net.ipv6.conf.all.autoconf=0, sysctl -w net.ipv6.conf.default.accept_ra=0, sysctl -w net.ipv6.conf.all.disable_ipv6=1 Commented Feb 24, 2016 at 23:52
  • @Manohar I can't thank you enough for your answer. Disabling ipv6 was the easiest workaround and saved my tons of hours Commented May 23, 2021 at 11:49

2 Answers 2

1

You can change that behavior by editing /etc/gai.conf and uncomment precedence ::ffff:0:0/96 100.

That will however affect more than just curl.

0

In my case, disabling IPv6 globally does not work

I still watch a 5s "initialization" delay.
Only the -4 argument works. (Same thing with wget command)

I've also tried to force iptables rejecting IPV6 traffic.
↪ Nothing changes

DNS

My tests show that it's the name resolutions that runs this delay.
If I curl an IP based URL, it's done instantly.

What's strange is that name resolution itself, made with nslookup is instant (and contains no IPV6 answer)

3
  • If I put static name resolution in /etc/hosts file, it works. But such a bad way... Commented Sep 8, 2022 at 9:49
  • I've also tried curl alternative such as httpie : much better. Why curl & wget try to resolv IPV6 specifically Commented Sep 8, 2022 at 9:55
  • The developers of curl and wget saw that IPv6 is being used more often and enabled support in the source code. If you open a bug in the source code respositories for them, the developers will likely either say disable IPv6 in the souce code and recompile or use the command-line options to disable IPv6. Commented Oct 12, 2022 at 0:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.