HostOnNet Blog

Setting HostName in Linux

Looking for Linux Server Admin or WordPress Expert? We can help.

To set host name on a CentOS/RHEL/Fedora Server to serverX.hosthat.com

Edit /etc/sysconfig/network

vi /etc/sysconfig/network

Find

HOSTNAME=old.hostname

Replace With

HOSTNAME=serverX.hosthat.com

Edit /etc/hosts

vi /etc/hosts

Add

SERVERS_MAIN_IP serverX.hosthat.com serverX

To find servers main IP, use ifconfig, it should be IP of eth0 in most cases.

Add hostname to /etc/hostname

echo serverX.hosthat.com > /etc/hostname

Setting HostName With out reboot

/bin/hostname -F /etc/hostname

Reboot Server

Finally you need to reboot. Make sure you done the changes properly before rebooting. If you made some mistake, server may not come back online with out assistance from Data Center, not every DC will do this, you may need to fix yourself by logging into KVM or rebooting server into rescue mode, so always verify before rebooting.

reboot

Verify Host Name Change

hostname

Should know new hostname.

Posted in CentOS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.