[CentOS] Changing hostname?
Nifty Cluster Mitch
niftycluster at niftyegg.com
Tue Sep 16 21:05:10 UTC 2008
On Sat, Sep 13, 2008 at 08:06:46AM +0200, Niki Kovacs wrote:
> I recently made a CentOS install on a machine with an unsupported
> network card. I had to add the driver for it later, once I finished the
> install. For now I have this:
> [kikinovak at localhost ~]$ hostname --fqdn
> Q: how would I change this to something like calimero.local?
> Here's what I *would* do, but I prefer to ask before.
> 1) edit /etc/sysconfig/network and edit this line:
> 2) add a line to /etc/hosts like this:
> # 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
> Please correct me if I'm wrong.
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.
127.0.0.1 localhost.localdomain localhost
associated the ipaddress 127.0.0.1 with the name localhost.localdomain
and its CNAME/ alias localhost.
This second line is interesting
127.0.0.1 calimero.local calimero
It appears to redefine the relationship with 127.0.0.1
If you were programing and had two lines
You would expect the second assignment for foo to win and the
second to be lost. It is possible that the pair of lines acts
a bit like a =+ assignment I would have to check.
A better line would be
127.0.0.1 localhost.localdomain calimero.local calimero
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
Having HOSTNAME set in places like
with a line like:
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.
One advantage of caching the name of the host permits the like of dynamic DNS to work....
and lots more like on line off line operation for mail composition and more.
In the case of swapping out the network card you need to look at /etc/sysconfig/network.scripts
and /etc/modprobe.conf with a multiple network card admin hat on. It may be as simple as
removing the old network interface (old hardware) and adding a new one with the
same name. The graphical tools may make this way easy...
In the system and in the internet there are commonly aliases for things.
For example eth0 is the common alias (sometimes defined in /etc/modprobe.conf) for
ethernet ports. See also /etc/sysconfig/network-scripts/ifcfg-eth0
for lines like "DEVICE=eth0" Aliases permit lots of layers of scripts to run
without knowing the specific driver name.
If you reflect back on your initial install, you were asked if the host name
was obtained from DHCP or was set (known) locally. So "it depends"... on decisions
you made and also external decisions.
T o m M i t c h e l l
Found me a new hat, now what?
More information about the CentOS