From: Wayne on
On 8/11/2010 2:40 PM, 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?

(This of OT here, try a networking group.) /bin/hostname
returns the kernel's idea of your hostname; dig, host, nslookup,
getent, and no doubt other utilities I can't remember, all do
a lookup; usually returning the DNS system's idea of the name
associated with some IP address (usually the first address bound
to the first detected NIC).

The kernel's hostname (also known as a nodename) is not dependent on
DNS or any IP address. The host name is usually set at boot time
from some RC script. On Fedora Linux for example, this is set
in the file /etc/sysconfig/network, which is read by several
init scripts.

A similar problem can occur due to caching of names. Then when
you change the name the cache still reports the old value. /bin/hostname
doesn't do any lookup so this isn't the problem in your case, but if
you've recently updated your DNS data (or /etc/hosts file or other
host DB), make sure to flush the name service cache.

Finally, some services ignore both the DNS and kernel's idea of the
hostname and use a setting in their configuration files to determine
the server's name. Apache, Postfix (MTA), and many others may set
the server name. Usually you need to run a shell script (see? I worked
that in) to find all occurrences of the old hostname in all files under
/etc.

--
Wayne
From: Bill Marcum on
On 2010-08-11, 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?

Your /etc/hosts file contains the correct hostname for a particular IP
address. Is that the same IP address shown by '/bin/hostname -i' ?
Another thing you might check is the DHCP configuration. If your machine
is a DHCP client, the server might be feeding it the old hostname.


--
Vacuums are nothings. We only mention them to let them know we know
they're there.
First  |  Prev  | 
Pages: 1 2
Prev: Search for 2 strings
Next: vi key bindings