gai.conf(5)

๐Ÿ’– gai.conf โ€” the girliepop guide to the getaddrinfo(3) config file ๐Ÿ’–

okay bestie, so this is gai.conf(5) from the File Formats Manual, and it's literally the glow-up file for how your system sorts DNS answers. pull up a chair, we're doing this together ๐Ÿซถ


โœจ NAME โœจ

gai.conf โ€” the configuration file for getaddrinfo(3) ๐Ÿ’…


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so here's the tea: when you call getaddrinfo(3), it might hand you back multiple answers. not one. multiple. and per RFC 3484, those answers have to be sorted so the one with the highest success rate comes first in the list. RFC 3484 ships an algorithm for that sorting, which is great, except the static rules are not always adequate, and honestly? same. static rules could never.

so the RFC itself says: sysadmins need the ability to dynamically change the sorting. iconic of it. and for the glibc implementation, that's exactly what the /etc/gai.conf file is for. main character energy fr fr โœจ

each line in the config file is a keyword plus its parameters. white spaces anywhere? ignored, we don't see them. lines starting with # are comments and get ignored too (self-care).

the keywords currently recognized are:

  • label netmask label โ€” this value gets added to the label table used in the RFC 3484 sorting. โš ๏ธ big warning: if any label definition is present in the config file, the default table is not used. so all the label definitions from the default table that you want to keep? you have to duplicate them yourself. yes, manually. i know. after the keyword, the line has to contain a network mask and a label value.
  • precedence netmask precedence โ€” similar to label, but instead the value gets added to the precedence table as specified in RFC 3484. and once again: the presence of a single precedence line in the config file causes the default table to not be used. one line, whole table gone, that's the vibe ๐Ÿ’€
  • reload <yes|no> โ€” controls whether a process checks whether the config file has been changed since the last time it was read. if the value is "yes", the file is reread. โš ๏ธ this might cause problems in multithreaded applications and is generally a bad idea. the default is "no". lowkey just leave it.
  • scopev4 mask value โ€” adds another rule to the RFC 3484 scope table for IPv4 addresses. by default, the scope IDs described in section 3.2 in RFC 3484 are used. changing these defaults should hardly ever be necessary โ€” like, bestie, please don't.

๐ŸŽ€ FILES ๐ŸŽ€

  • /etc/gai.conf

๐ŸŒˆ VERSIONS ๐ŸŒˆ

the gai.conf file is supported since glibc 2.5. vintage but still serving ๐Ÿ‘‘


๐Ÿฆ‹ EXAMPLES ๐Ÿฆ‹

the default table according to RFC 3484 would be specified with this configuration file:

label  ::1/128       0
label  ::/0          1
label  2002::/16     2
label ::/96          3
label ::ffff:0:0/96  4
precedence  ::1/128       50
precedence  ::/0          40
precedence  2002::/16     30
precedence ::/96          20
precedence ::ffff:0:0/96  10

and plot twist โ€” glibc includes some extra rules in the label table for site-local addresses, ULA, and Teredo tunnels. its default label table is:

label ::1/128        0
label ::/0           1
label 2002::/16      2
label ::/96          3
label ::ffff:0:0/96  4
label fec0::/10      5
label fc00::/7       6
label 2001:0::/32    7

โญ SEE ALSO โญ


and that's the whole page, bestie ๐Ÿ’œ this was Linux man-pages 6.20, dated 2026-02-08 โ€” so go forth, sort those addresses, and remember: don't touch scopev4 unless you absolutely have to. mwah ๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: GPL-2.0-only
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms