Checking if my hostname is correct (ovh vps + centos7)

Simohammedhttc asked:

I recently purchased a VPS from OVH with Centos 7 preinstalled. I want to make sure my hostname is correctly set.

According to some tutorials:

hostname returns the hostname
hostname -f returns the FQDN

After executing these commands, I got the same result: vpsxxxxxxxx.ovh.net
I thought hostname and FQDN are different!

cat /etc/hosts

127.0.0.1 – localhost
IP – vpsxxxxxxxx.ovh.net – vpsxxxxxxxx

I am confused, I have linked a domain name that I have purchased separately to my VPS, I am also planning to add another domain name to run two sites in my VPS.

Is my hostname correct?
How can we call vpsxxxxxxxx.ovh.net? An external domain name, an internal domain, a hostname, a subdomain of ovh.net?
What about the two domains names that I have linked to the VPS? Do they need some configurations in /etc/hosts?

I have to fix these issues to enable postfix mail server.

My answer:


The hostname should always be set to the FQDN in CentOS 7, according to Red Hat’s recommendations.

A host name can be a free-form string up to 64 characters in length. However, Red Hat recommends that both static and transient names match the fully-qualified domain name (FQDN) used for the machine in DNS, such as host.example.com. It is also recommended that the static and transient names consists only of 7 bit ASCII lower-case characters, no spaces or dots, and limits itself to the format allowed for DNS domain name labels, even though this is not a strict requirement. Older specifications do not permit the underscore, and so their use is not recommended.

If you’re running email on the server, then the hostname should be set to one in a domain that you control, rather than one controlled by your service provider. You do not need to place it in /etc/hosts, provided that the appropriate DNS entries exist for the name.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.