How to Setup a Fully Qualified Domain Name on CentOS
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 mymail.mydomain.com. 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
1 |
hostname |
If you are using CentOS 7 / RHEL 7, a better way to display the hostname is by using the following command
1 |
hostnamectl status |
The server will output host related information such as Machine ID, Operating System and more.
Changing Hostname in CentOS 7
Changing the hostname using CentOS 7 is pretty easy
1 |
hostnamectl set-hostname pandora.mydomain.com |
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.
1 |
nano /etc/sysconfig/network |
Locate the HOSTNAME line and replace it’s value to your desired FQDN. I used pandora.mydomain.com as an example
1 |
HOSTNAME=pandora.mydomain.com |
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.
1 |
nano /etc/hosts |
We need to add a new entry at the bottom of the file. Assuming that our IP address is 11.22.33.44 and assuming that our FQDN pandora.mydomain.com
1 |
11.22.33.44 pandora.mydomain.com pandora |
Finally, we need to restart to see the changes.
1 |
/etc/init.d/network restart |
Enjoy!
1 Response
[…] Finally follow this tutorial “How to setup a fully qualified domain name” […]