gai.conf - Linux


gai.conf is a configuration file in Linux that stores global DNS settings for the GNU C Library (glibc). It allows administrators to specify DNS servers, search domains, and other DNS-related options for the system, ensuring consistent DNS resolution behavior across applications.


# syntax: name value
# name = "name"
# value = either "string" or "number"
# Any entry may be followed by '#' and comment text.
# The file must not contain lines consisting solely of '#' and comment text.
options ndots:5


| Option | Description | Default Value |
| search | Specifies up to six DNS search domains. | unset |
| nameserver | Sets the primary and secondary DNS servers. | unset |
| domain | Sets the default domain for unqualified hostnames. | unset |
| broadcast | Enables broadcasting DNS queries. | off |
| ndots | Specifies the number of dots in a name before a search is performed. | 1 |
| inet6 | Enables IPv6 DNS resolution. | off |
| timeout | Sets the timeout for DNS queries in seconds. | 5 |
| attempts | Number of retries for failed queries. | 2 |
| rotate | Rotates between configured DNS servers. | off |
| edns0 | Enables EDNS0 support for larger DNS packets. | off |
| ip6-bytestring | Specifies the format of IPv6 addresses in DNS requests. | unset |


Configure primary and secondary DNS servers:


Specify search domains:


Enable broadcasting DNS queries:

broadcast on

Increase timeout for DNS queries:

timeout 10

Common Issues

  • Unresolved hostnames: Ensure that the correct DNS servers are configured and that the network is configured to use the system DNS settings.
  • Slow DNS resolution: Check the configured DNS servers for performance issues or consider using a different DNS provider.
  • DNS conflicts: If multiple DNS servers are configured, ensure that they provide consistent information.


Combine with resolvectl: Configure DNS settings dynamically using the resolvectl command.

resolvectl config
resolvectl status

Use with DHCP: The DHCP server can provide DNS settings to clients. Configure gai.conf to use the DHCP-provided DNS settings.

dhclient -r

Related Commands

  • resolv.conf: Stores DNS settings specific to a network interface.
  • nslookup: Looks up DNS records for a specified hostname or IP address.
  • dig: A more advanced DNS lookup tool with additional options.