3

I have a RHEL7.0 host which has this standard entry in /etc/hosts/:

127.0.0.1 localhost.localdomain localhost

So resolving localhost.localdomain works:

$ ping localhost.localdomain
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.

But trying to resolve the absolute version of the same fails:

$ ping localhost.localdomain.
ping: unknown host localhost.localdomain.

And in general, trying to resolve absolute FQDNs against relative /etc/hosts entries fails. Now, if I change the entry in /etc/hosts to have a trailing period, I can then resolve the absolute FQDN. But then I can no longer resolve the relative FQDN. Seems if I want both absolute and relative forms to resolve, I have to explicitly include both forms of the FQDN in /etc/hosts.

Is this odd behavior described in an RFC or standard somewhere so I can understand it better? Is it configurable somehow?

  • What does your nsswitch.conf file have for hosts? – Jeff Schaller Jul 3 '15 at 0:24
  • @JeffSchaller: hosts: files dns myhostname – John Dough Jul 6 '15 at 22:36
  • related: unix.stackexchange.com/questions/166083 this is likely not specified anywhere, but just an implementation detail of resolver library (on modern systems, nss_files module). – sendmoreinfo Sep 25 '15 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.