How to Setup a Fully Qualified Domain Name on CentOS

Setup a fully qualified domain name

Setup a fully qualified domain name

In the computer and networking world, there is a nodename that is well used and yet at the same time called upon to be deprecated by some server admins. The nodename is called “hostname”  which basically is a label assigned to the connected device in a computer network. This is widely used to identify the device from various forms of  electronic communication such as the World Wide Web, e-mail or Usenet.

What we are after is to create a hostname in a fully qualified domain name (FQDN) format, sometimes also referred to as an absolute domain name. A fully qualified domain name (FQDN) is the complete domain name for a specific computer, or host, on the Internet. The FQDN consists of two parts: the hostname and the domain name. For example, an FQDN for a hypothetical mail server might be In order to make things easier to digest, view a FQDN as a subdomain inside your domain.

Checking the Current Hostname

You can easily check your current hostname using the hostname command

If you are using CentOS 7 / RHEL 7, a better way to display the hostname is by using the following command

The server will output host related information such as Machine ID, Operating System and more.

Console Hostname

Console Hostname

Changing Hostname in CentOS 7

Changing the hostname using CentOS 7 is pretty easy

Changing Hostname in CentOS 6

Changing the hostname in centOS 6 requires more work, we need to use our favorite editor and mine is nano. All important configuration files by default resides in /etc/ and we are looking for network file config.

Locate the HOSTNAME line and replace it’s value to your desired FQDN. I used as an example

An extra step is needed to make sure that we have a FQDN, please note that we only have resolved the hostname part. The second part requires an edit to the hosts file.

We need to add a new entry at the bottom of the file. Assuming that our IP address is and  assuming that our FQDN

Finally, we need to restart to see the changes.



The TechnoJunkie of the group who studied engineering but got stuck with software development. Remember kids, 90% of your problems can be solved by marketing. Solving the other 10% just requires good procrastination skills.

You may also like...

1 Response

  1. January 15, 2016

    […] Finally follow this tutorial “How to setup a fully qualified domain name” […]

Leave a Reply

%d bloggers like this: