host.conf(5)
๐ host.conf(5) โ bestie's guide to the resolver config file ๐
okay so before we even start: this is host.conf(5), and it lives in the File Formats Manual section of the man pages (section 5, the file-formats girlies ๐). grab a snack, we're doing the resolver's lil config file.
โจ NAME โจ
host.conf โ the resolver configuration file, no cap ๐ฆ
๐ธ SYNOPSIS ๐ธ
/etc/host.conf
๐ DESCRIPTION ๐
So the file /etc/host.conf holds all the configuration info that's specific to the resolver library. That's it, that's the whole vibe.
The rules of the house: it should have one configuration keyword per line, and then the appropriate configuration info follows after it. Like, keyword first, details second, every single line. ๐
These are the keywords it recognizes, and yes we're going through all of them, bestie:
trimโ this one is the main character and it's allowed to show up more than once โจ Every time it appears it should be followed by a list of domains, separated by colons (':'), semicolons (';') or commas (','), with the leading dot. When it's set, the resolver library will automatically trim that given domain name off the end of any hostname that got resolved via DNS. It's meant for local hosts and domains. (Related note, and this is important:trimwill not affect hostnames gathered via NIS or via thehosts(5)file. So be careful โ you need to make sure the first hostname for each entry in the hosts file is fully qualified or unqualified, whichever is appropriate for your local installation. no notes, just facts ๐)multiโ valid values areonandoff. If you set it toon, the resolver library will return all valid addresses for a host that shows up in the/etc/hostsfile, instead of just the first one. It'soffby default though, and honestly? iconic of it, because turning it on may cause a substantial performance loss at sites with big hosts files. ๐ญreorderโ valid values areonandoff. Set it toonand the resolver library will attempt to reorder host addresses so that local addresses (like, ones on the same subnet) get listed first when agethostbyname(3)is performed. The reordering happens for all lookup methods. Default value isoff. periodt.
๐ฆ ENVIRONMENT ๐ฆ
These environment variables let users override the behavior that's configured in /etc/host.conf. yes, override. the users have that power ๐ซถ
RESOLV_HOST_CONFโ if it's set, this variable points to a file that should be read instead of/etc/host.conf.RESOLV_MULTIโ overrides themulticommand.RESOLV_REORDERโ overrides thereordercommand.RESOLV_ADD_TRIM_DOMAINSโ a list of domains, separated by colons (':'), semicolons (';'), or commas (','), with the leading dot, which will be added to the list of domains that should be trimmed.RESOLV_OVERRIDE_TRIM_DOMAINSโ same deal: a list of domains, separated by colons (':'), semicolons (';'), or commas (','), with the leading dot, but this one will replace the list of domains that should be trimmed. It overrides thetrimcommand. ๐
๐ FILES ๐
/etc/host.confโ resolver configuration file/etc/resolv.confโ resolver configuration file/etc/hostsโ local hosts database
โญ NOTES โญ
here's the tea โ โ the following differences exist compared to the original implementation:
A new command spoof and a new environment variable RESOLV_SPOOF_CHECK can take arguments like off, nowarn, and warn.
Also, line comments can appear anywhere, not only at the beginning of a line. glow up โจ
๐ Historical ๐
The nsswitch.conf(5) file is the modern way of controlling the order of host lookups. (iykyk โ if you know you know, and if you don't, go read that one next ๐ง)
In glibc 2.4 and earlier, this keyword was recognized:
orderโ this keyword specifies how host lookups are to be performed. It should be followed by one or more lookup methods, separated by commas. Valid methods arebind,hosts, andnis.RESOLV_SERV_ORDERโ overrides theordercommand.
Since glibc 2.0.7, and up through glibc 2.24, the following keywords and environment variable were recognized but never implemented โ so like, they were there, but they were not there there ๐:
nospoofโ valid values areonandoff. If set toon, the resolver library will attempt to prevent hostname spoofing to enhance the security ofrloginandrsh. How it works: after performing a host address lookup, the resolver library will perform a hostname lookup for that address. If the two hostnames do not match, the query fails. The default value isoff.spoofalertโ valid values areonandoff. If this option is set toonand thenospoofoption is also set, the resolver library will log a warning of the error via the syslog facility. The default value isoff.spoofโ valid values areoff,nowarn, andwarn. If this option is set tooff, spoofed addresses are permitted and no warnings will be emitted via the syslog facility. If it's set towarn, the resolver library will attempt to prevent hostname spoofing to enhance the security and log a warning of the error via the syslog facility. If it's set tonowarn, the resolver library will attempt to prevent hostname spoofing to enhance the security but not emit warnings via the syslog facility. Setting this option to anything else is equal to setting it tonowarn.RESOLV_SPOOF_CHECKโ overrides thenospoof,spoofalert, andspoofcommands in the same way as thespoofcommand is parsed. Valid values areoff,nowarn, andwarn.
๐ SEE ALSO ๐
gethostbyname(3), hosts(5), nsswitch.conf(5), resolv.conf(5), hostname(7), named(8)
and that's the whole page bestie, slay ๐ โจ
this gorgeous little number is from Linux man-pages 6.20, dated 2026-02-08, and it covers host.conf(5) ๐ฆ mwah, go touch some config files ๐
๐ฆ 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-or-later
- Copyright 1997, Martin Schulze <joey@debian.org>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms