Checklist for changing the hostname of a server [closed]

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.


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.


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