13
votes

I want to rename one of my Debian linux servers to give it a more descriptive, role-based name.

Here are the places I know the name will need to be changed:

  • /etc/hostname & /etc/mailname & execute hostname command
  • /etc/hosts
  • /etc/hosts on other servers, such as our remote log server
  • /etc/password (I normally rename root to match the server name, makes sorting mail easier)
  • Logwatch / Logcheck configuration
  • "rkhunter --propupd" needs to be run
  • Backup client configuration - Backup Server Configuration
  • Name in heartbeat or keepalive configuration (on all cluster servers) if this is part of a cluster
  • /etc/drbd.conf (if there are shared drbd drives)
  • DNS server - both internal and external
  • Server Name in Virtual Center (this is a virtual server)
  • Name in Nagios / OpsView or other monitoring software
  • References in server documentation

What have I overlooked? Are there other common things that need to be changed when renaming a server?

4 Answers 4

6
votes

A few other things to check:

  • If you run MySQL, don't forget to update it as well. By default, mysql_install_db will add entries to the mysql.user table allowing access from the server's own hostname. It usually adds localhost as well, so you're probably ok here, but it's worth doublechecking to make sure you don't lock yourself out.

  • If you're running Apache, make sure you update the ServerName globally and in any virtual hosts that may have been using the old canonical hostname.

  • If you're running a mail server (Sendmail, Postfix, etc.), make sure it can figure out its own hostname. For instance, Postfix will try to automatically fill in $myhostname, but that won't help if you've manually overridden it in /etc/postfix/main.cf.

  • If this server talks to others that are set up to perform access control based on hostname (e.g. /etc/exports for NFS, /etc/hosts.allow, etc.) you will need to update those as well.

  • If you have any SSL keys using the server's old hostname as the common name (CN), you will need to recreate them using the new hostname and issue new certificate requests. Hopefully they're self-signed so you don't have to pay someone for the new certs. Strictly speaking, SSL will still work if you don't do this, but clients will usually pop a warning message about the name mismatch.

There certainly may be others depending on the applications you run.

4
votes

I'd do it in a "mass grep" way. For example:

$ grep -rin "hostname" / > /my/output/file.txt

and examine file.txt when it finishes.

Reason for that being that it's nearly impossible to accurately know where hostname/ip changes are needed, even if you're on top of your config, users might configure their software to depend on it, blind search tends to avoid such trouble before it arises.

3
votes

You could always just add another entry in your hosts files on other machines on the local network (if feasible) so that the machine responds to both:

[root@165 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost.localdomain localhost
78.119.15.19    myserver.net myserver
78.119.15.20    myserver2.net myserver2 another_name yet_another

In the above example myserver.net would be the local machine, myserver2.net would be the remote machine you are aliasing

2
  • Great point. I did this in DNS so that the old name would be around for awhile
    – Brent
    Jul 23, 2009 at 15:53
  • It can be helpful for a machine to have its own name that never changes and additional names relating to its current purpose. Different clients and services refer to it by the most appropriate name.
    – mas
    Jul 23, 2009 at 16:56
1
vote

When I rename my Ubuntu hosts (happens fairly often since I clone a virtual machine regularly for different tests) I not only have to do...

sudo grep -R oldhostname /etc/*

But I also have to re-run the postfix configuration. Just editing the config files doesn't change everything thing.

sudo dpkg-reconfigure postfix

After making those changes and restarting everything is good to go.

Not the answer you're looking for? Browse other questions tagged .