[chef] Re: Re: Re: fqdn and hostname


Chronological Thread 
  • From: Lamont Granquist < >
  • To: < >
  • Subject: [chef] Re: Re: Re: fqdn and hostname
  • Date: Thu, 24 Jan 2013 11:52:52 -0800


typical nsswitch.conf configuration is for /etc/hosts to override DNS in which case it just does a scan for the first line matching the IP address and returns the first name on that line.  i suspect that if the OP simply reverses the order on that line that it'll start returning the FQDN correctly.

and i typically use chef to enforce nsswitch.conf settings and write out /etc/hosts to have the primary IP address of the host resolve this way so there's no ambiguity.

On 1/24/13 11:37 AM, Dan Razzell wrote:
" type="cite"> A reverse lookup has different semantics depending on context.  This can cause unexpected behavior.

1) The object returned from gethostbyaddr() contains a list of host aliases and a list of addresses.  In other words, it's perfectly reasonable for there to be multiple hostnames associated with a single address.  Ordering is not guaranteed in either list.  However the object also has an attribute for the official hostname.  Whether that is the long or the short name depends on how the underlying database is configured.  For that, see the man page for nsswitch.conf.  Conventions vary from one site to another.

2) If your nsswitch.conf causes the reverse lookup to be passed to DNS, the behavior when there are multiple PTR records for a given address is undefined.  You might get a list.  You might get a singleton that is round-robined.  You might consistently get the same singleton from one DNS server and a different singleton from another.  You might get nothing.

On 13-01-24 10:47 AM, Lamont Granquist wrote:
" type="cite">
when you're doing a reverse lookup on 1.2.3.4 with that config you're getting back the first name which is the short hostname.  to get the FQDN just reverse that to:

1.2.3.4 machine1.example.com machine1






Archive powered by MHonArc 2.6.16.

§