[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: changing a computer's name



Jeff Cours <linux-j@moriarti.org> [2002-12-05 11:39:00 -0800]:

> Good catch - I forgot to mention that one. I did modify /etc/hosts 
> originally, adding the new name in addition to the old name to the 
> loopback (127.0.0.1) entry. I don't know whether or not the resolver 
> is sensitive to ordering, though, so I just rearranged the order so 
> the new name is first, followed by "localhost", followed by the old 
> name. Maybe that'll make a difference.

Yes, it is sensitive to the ordering.  The first name on the line is
the hostname and the others on the line are aliases.  Also, the
contents of /etc/nsswitch.conf controls whether files or DNS is
first.  The default is files and so the local /etc/hosts will have
precedence over DNS.

You want the fully qualified hostname first on the line.  Normally
that is followed by the name without the domain as an alias and for
the 127.0.0.1 entry by localhost so that it is also an alias.  (Having
it the other way around will, for example, cause 'hostname -fqdn' to
return the wrong result and cause other errors.)  Hard to describe so
here is an example.

  127.0.0.1       torment.proulx.com torment localhost

Other configurations are also possible.  There is probably no Right
Configuration for all systems.  It is also okay to just have localhost
there and then use DNS and the loopback device for local host
networking.  On a fully networked machine that would be fine.  But on
a host where the networking is brought up and down such as a laptop or
a desktop that runs ppp only sometimes then using 127.0.0.1 for local
networking when the Real Networking is offline works well.

The list of files you gave earlier in the thread to change when
chaning the hostname looked fine.  And I know you said you rebooted.
It is possible to change the hostname on the fly without rebooting by
restarting all of the daemons.  But frequently it is just easier to
reboot so everything comes up clean and you test that it does.
Otherwise when you do reboot some years in the future to change
hardware if it is not clean then so much time will have passed that
you will have forgotten what you changed!

> Also, how do I generate public keys with the correct host name
> (or can I just edit the hostname in /etc/ssh/ssh_host_rsa_key.pub and
> /etc/ssh/ssh_host_dsa_key.pub)?

The name in those files are in the comment section of the file.  You
can either ignore them entirely and everything will work okay.  Or if
you want to eradicate any trace of the old name then feel free to edit
them by hand and change the machine name in the comment there.

Bob

Attachment: pgpcdC2hIHf52.pgp
Description: PGP signature


Reply to: