Friday, April 9, 2010

Changing the hostname of a RHEL 5.4 server

Sometimes we need to change the hostname of a configured server to reflect its new hostname.  And we will most likely do it if we have just cloned a new drive and connected it to a new server. This can be done with the following steps below.

[root@base ~]# vi /etc/sysconfig/network

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=nfs00.example.com

The configuration above makes sure that the new hostname (fqdn to be exact) will be persistent and will stick after a reboot.

[root@base ~]# hostname nfs00.example.com
[root@base ~]# uname -a
Linux nfs00.example.com 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:54 EDT 2009 i686 i686 i386 GNU/Linux
[root@base ~]# hostname 
nfs00.example.com
[root@base ~]# 

Notice that the output of the uname -a command or hostname already shows the intended hostname for this system. But on the shell, it still says its base. At this point we need to logout and login again in order for us to get the new hostname.

Connection to 192.168.56.101 closed.
motto:~ motto$ ssh root@192.168.56.101
root@192.168.56.101's password: 
Last login: Fri Apr  9 14:32:27 2010 from 192.168.56.1
[root@nfs00 ~]# 

Voila! Our servers hostname is now nfs00.

No comments:

Post a Comment