So, after finding the hostname command doesn’t do the whole job, it was quite important that this setting would survive a reboot!
# hostname testbox.domain.com
Edit the /etc/sysconfig/network file so that the “HOSTNAME” variable is set to your new hostname:
It is a good idea to add an entry in /etc/hosts for this hostname (saves going out to the internet only to return back again):
127.0.0.1 localhost.localdomain localhost localhost4.localdomain4 localhost4 testbox.domain.com testbox
Alternatively if you require to point outside for some reason then do something like the following and change your ip address to your public/network ip:
184.108.40.206 testbox.domain.com testbox
I added two entries above, this allows you to either use testbox.domain.com or just testbox as a destination (i.e. ssh testbox).
Restart (r)syslog and crond. Check to see if it is now showing the correct hostname:
# service crond restart # service *syslog restart # tail /var/log/messages
/var/log/messages should now have changed the hostname to the new one.
If you are running an SMTP server on this host you could see what it returns:
# telnet localhost 25
It should say something like:
220 testbox.domain.com ESMTP Postfix