Bug 19697

Summary: /etc/gai.conf option to configure AF_UNSPEC lookups
Product: glibc Reporter: Florian Weimer <fweimer>
Component: networkAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: pemensik, stsp, walter.sourceware
Priority: P2 Flags: fweimer: security-
Version: 2.24   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Bug Depends on:    
Bug Blocks: 30544    

Description Florian Weimer 2016-02-20 14:22:27 UTC
Systems without IPv6 connectivity may still run software which uses AF_UNSPEC lookups.  Such systems may want to skip the AAAA lookup in getaddrinfo.

Similarly, IPv6-only systems might want to avoid the A lookups.

Therefore, configuration options like “af_unspec both“ (the default), “af_unspec af_inet” and “af_unspec af_inet6” make a lot of sense to me.
Comment 1 Walter Doekes 2020-08-17 10:07:27 UTC
Seeing that this is still an issue and this bug is referenced here and there, I'd like to shamelessly plug nss-dns4only [1] which uses the nsswitch subsystem to replace AF_UNSPEC queries.

You may find it useful.

Cheers,
Walter Doekes
OSSO B.V.

[1] https://github.com/ossobv/nss-dns4only
Comment 2 Stas Sergeev 2021-05-05 22:22:45 UTC
(In reply to Walter Doekes from comment #1)
> [1] https://github.com/ossobv/nss-dns4only

Many thanks for the link!
The only working solution I've
found in a few days of searching...
Comment 3 Petr Menšík 2023-06-12 15:01:46 UTC
I made alternative proposal in bug #30544. I think it should not be done in gai.conf, but instead in /etc/resolv.conf only. Alternative resolution way like mdns can resolve IPv6 even if the network does not support it. But DNS protocol is not related to specific interface and replies cannot contain scope_id, so something similar cannot ever work there. Link-local addresses over DNS will not work well, especially when connected by multiple interfaces.

localhost and other files should still work.