Changing the hostname on Red Hat Enterprise Linux
So I have to change the hostname on a server running Red Hat Enterprise Linux (v5). As I have to do this quite often I figured that I would note down where I need to change it.
-
Update the HOSTNAME entry in
/etc/sysconfig/network
-
Update the entry in
/etc/hosts
to have the correct new hostnames both with domains and without. -
Update the list of hostnames that sendmail will accept emails for in
/etc/mail/local-host-names
. -
run
hostname <NEW_HOSTNAME>
-
This will update the hostname there and then, and avoids the need to restart the server to pick up the new hostname.
-
Finally, if your server has DNS entries pointing to it update these to include the new hostname.