Fedora 41/42/43
Gnome Software takes ages to load or download updates. It often times out when downloading them, displaying the following message:
Curl error (28): Timeout was reached for https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-43&arch=x86_64 [Connection timed out after 5001 milliseconds]
The timeout is 5s due to the DNF configuration, so it won’t take too long to fail.
It seems that Gnome Software is failing to update packages faster due to cURL IPv6 preference.
I have set the /etc/gai.conf file to prefer IPv4 connections.
precedence ::1/128 50
precedence ::/0 40
precedence 2002::/16 30
precedence ::/96 20
precedence ::ffff:0:0/96 100
$ getent ahosts mirrors.rpmfusion.org
78.47.223.143 STREAM mirrors.rpmfusion.org
78.47.223.143 DGRAM
78.47.223.143 RAW
158.69.60.128 STREAM
158.69.60.128 DGRAM
158.69.60.128 RAW
2607:5300:201:3100::9322 STREAM
2607:5300:201:3100::9322 DGRAM
2607:5300:201:3100::9322 RAW
2a01:4f8:c0c:bed0::1 STREAM
2a01:4f8:c0c:bed0::1 DGRAM
2a01:4f8:c0c:bed0::1 RAW
However, when I run some cURL commands, they seem to translate the domain to an IPv6 address first instead of an IPv4 address.
$ curl -v -L https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-43&arch=x86_64
* Host mirrors.rpmfusion.org:443 was resolved.
* IPv6: 2607:5300:201:3100::9322, 2a01:4f8:c0c:bed0::1
* IPv4: 78.47.223.143, 158.69.60.128
* Trying [2607:5300:201:3100::9322]:443...
* Trying 78.47.223.143:443...
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
(...)
When this happens, the process gets stuck and cannot reach the destination resource.
Adding the -v4 option to cURL makes it work, and the data is parsed. However, it uses only IPv4 and ignores IPv6 completely.
$ curl -v4 -v https://mirrors.rpmfusion.org/metalink?repo=nonfree-fedora-43&arch=x86_64
* Host mirrors.rpmfusion.org:443 was resolved.
* IPv6: (none)
* IPv4: 78.47.223.143, 158.69.60.128
* Trying 78.47.223.143:443...
* ALPN: curl offers h2,http/1.1
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
(...)
I also tried adding the --happy-eyeballs-timeout-ms 0 option to prefer IPv4, but allow IPv6 fallback. Still, the behavior is the same; cURL ends up preferring IPv6.
My DNF configuration (/etc/dnf/dnf.conf) already uses the ip_resolve=4 option. This resolved the timeout issue with Fedora mirrors when updating with DNF.
However, there are other applications that use cURL in the backend, and I can’t configure them to use only IPv4.
How can I configure cURL or Gnome Software to always prefer IPv4 over IPv6 without disabling IPv6?