[CentOS] Changing hostname?

Wed Sep 17 06:36:33 UTC 2008
Marcus Moeller <mm at gcug.de>

Dear Tom.

> > # Do not remove the following line, or various programs
> > # that require network functionality will fail.
> > 127.0.0.1       localhost.localdomain   localhost
> > 127.0.0.1     calimero.local          calimero
> > ::1     localhost6.localdomain6 localhost6
> >
>
> Lots of replies to this already.  The critical thing to understand is
> that it is the network interfaces that have names not the box.
>
> Sendmail and some other tools look for host names that have at least
> one dot in them.  Thus localhost.localdomain gets paired with localhost
> as a CNAME.

I would suggest to use localhost localhost.localdomain (if it's really
required) instead. 127.0.0.1 should resolve to localhost only (as
mentioned before).

> A better line would be
>         127.0.0.1       localhost.localdomain calimero.local calimero
>  or perhaps...
>         127.0.0.1       localhost.localdomain calimero.localdomain calimero
>
> These make it clear that you want all four names (long and short) associated with 127.0.0.1

See above. Please do not add hostnames other than localhost to
127.0.0.1. Add the hostname to your network interface, instead.

> Having HOSTNAME set in places like
>        /etc/sysconfig/network
> with a line like:
>        HOSTNAME=calimero
> has advantages in lots of ways...  with wireless and other dynamic situations
> where plugging a wire in or wired connection to hot spots and more are possible
> keeping the 'hostname' handy makes sense for a handful of reasons.   Link local
> zeroconfig ....  It also permits the host to have the 'short' CNAME of calimero
> and still discover its fully qualified (lots of dots) host name.

If you just set HOSTNAME in /etc/sysconfig/network the hostname is set
during boot but is not resolvable. Therefore you should make sure that
/etc/hosts and HOSTNAME are set. The last one is optional (see
ifup-post in previous postings) but good-style.

Best Regards
Marcus