2

It seems that when resolving hosts on Alpine Linux, the default behavior is to try IPv6 first and falling back to IPv4.

But sometimes it takes a lot of time to resolve, and there are connections when IPv6 is blocked entirely making it frustating.

Is there a way to configure the resolver to try IPv4 first?

2 Answers 2

3

What is happening with Alpine Linux is that Alpine does not use glibc, rather it uses musl libc.


With glibc you could prefer IPv4 over IPv6 simply by adding this line to /etc/gai.conf:

precedence ::ffff:0:0/96  100

However, this does not work with Alpine, since the musl libc implementation of getaddrinfo(3) does not support this.

You can see the thread about this request here.

You can also see the wiki on Running glibc programs in Alpine.

1

I've just found that I can disable IPv6 entirely and that makes the trick for me.

Adding to /etc/sysctl.d/local.conf (source):

# Force IPv6 off
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1

And reloading the configuration:

# sysctl --system
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .