From: Lao Ming on
What makes /bin/hostname use an old DNS name instead of the name that /
usr/bin/dig displays? I have a script which uses $( hostname -s ) to
obtain the hostname. Even though the DNS update was done at least a
month ago, /bin/hostname continues to provide the name that I don't
want. I also have the hostname defined properly in /etc/hosts.
Should I mention it to the DNS admin or is there some way to force
getting the correct name?
From: pk on
On Wed, 11 Aug 2010 11:40:58 -0700 (PDT)
Lao Ming <laomingliu(a)gmail.com> wrote:

> What makes /bin/hostname use an old DNS name instead of the name that /
> usr/bin/dig displays? I have a script which uses $( hostname -s ) to
> obtain the hostname. Even though the DNS update was done at least a
> month ago, /bin/hostname continues to provide the name that I don't
> want. I also have the hostname defined properly in /etc/hosts.
> Should I mention it to the DNS admin or is there some way to force
> getting the correct name?

Check your /etc/hosts file.
From: Lao Ming on
On Aug 11, 11:35 am, pk <p...(a)pk.invalid> wrote:
> On Wed, 11 Aug 2010 11:40:58 -0700 (PDT)
>
> Lao Ming <laoming...(a)gmail.com> wrote:
> > What makes /bin/hostname use an old DNS name instead of the name that /
> > usr/bin/dig displays?  I have a script which uses $( hostname -s ) to
> > obtain the hostname.  Even though the DNS update was done at least a
> > month ago, /bin/hostname continues to provide the name that I don't
> > want.  I also have the hostname defined properly in /etc/hosts.
> > Should I mention it to the DNS admin or is there some way to force
> > getting the correct name?
>
> Check your /etc/hosts file.

You probably just missed my mention of it above. The /etc/hosts file
has the name as it should be. Thanks for your help.

From: pk on
On Wed, 11 Aug 2010 13:16:08 -0700 (PDT) Lao Ming <laomingliu(a)gmail.com>
wrote:

> On Aug 11, 11:35 am, pk <p...(a)pk.invalid> wrote:
> > On Wed, 11 Aug 2010 11:40:58 -0700 (PDT)
> >
> > Lao Ming <laoming...(a)gmail.com> wrote:
> > > What makes /bin/hostname use an old DNS name instead of the name
> > > that / usr/bin/dig displays?  I have a script which uses $( hostname
> > > -s ) to obtain the hostname.  Even though the DNS update was done at
> > > least a month ago, /bin/hostname continues to provide the name that I
> > > don't want.  I also have the hostname defined properly in /etc/hosts.
> > > Should I mention it to the DNS admin or is there some way to force
> > > getting the correct name?
> >
> > Check your /etc/hosts file.
>
> You probably just missed my mention of it above. The /etc/hosts file
> has the name as it should be. Thanks for your help.

Right, I missed it. Well, run "strace /bin/hostname" (or the equivalent
of strace for your platform) and see what it does, ie what files it reads
or what queries it performs.

PS: it's a bit OT here.

From: Icarus Sparry on
On Wed, 11 Aug 2010 11:40:58 -0700, Lao Ming wrote:

> What makes /bin/hostname use an old DNS name instead of the name that /
> usr/bin/dig displays? I have a script which uses $( hostname -s ) to
> obtain the hostname. Even though the DNS update was done at least a
> month ago, /bin/hostname continues to provide the name that I don't
> want. I also have the hostname defined properly in /etc/hosts. Should I
> mention it to the DNS admin or is there some way to force getting the
> correct name?

hostname will usually use whatever is configured in /etc/nsswitch.conf.
This can include /etc/hosts and dns, but it can also use NIS, NIS+, or
hesiod. It may also return whatever has been set by the "sethostname(2)"
system call, which sometime is set from files like /etc/hostname or /etc/
nodename as part of the system bootup.
 |  Next  |  Last
Pages: 1 2
Prev: Search for 2 strings
Next: vi key bindings