CentOS 6 – Hostname Tips and Tricks

This post covers a few of the hostname-related issues I used to have when launching new CentOS instances.

Note: If you find yourself constantly doing stuff like this by hand then consider looking into provisioning, CI, and configuration management tools such as Cobbler, kickstart, Ansible, Puppet, Chef, etc.

Change the Hostname (without rebooting)

1. Set the hostname

2. Edit network config file (/etc/sysconfig/network)

On a new line, add the following entry:

3. Edit the hosts file (/etc/hosts)

On a new line add the machine’s IP, the FQDN, and the simple hostname:

Set a Fully Qualified Domain Name (FQDN)

Adding the following to /etc/hosts

You can verify the FQDN with hostname -f

Pass Hostname and FQDN to the DHCP Server

If you are having a problem resolving a machine by its hostname or FQDN then add the following line to /etc/sysconfig/network-scripts/ifcg-eth0

Leave a Reply

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

×Mike Everhart

Need Some More Help? Let's Talk!

I'd love to work with you! Fill out the form below to schedule a free consultation to discuss your needs and how I can help.

Need More Help?