I have a Centos 7 server which has tens of domain names and IPs.

The IP addresses are pointing to my server.

Each domain name is pointing to its own IP via A record.

I want to configure my FQDN in order to install Postfix.

/etc/hostname contains myproject.localdomain

/etc/hosts contains:   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

Command hostname returns:


hostname -f returns:


domainname returns (none)

Do I have to choose a real domain purchased and prepend to it the hostname like this:

ip    hotname.domainame    hostname
  • That is always a good thing but you can leave it as it is – M A SIDDIQUI Feb 6 '17 at 14:00

Method 1)

You do not define your server's hostname or FQDN using the /etc/hosts file

You could edit /etc/hostname file and fill in your hostname and save the file. That would be just a part of the process

Then on CentOS 7 you have hostnamectl command:

hostnamectl set-hostname host.domain.tld --static

Method 2)

Use nmtui tool by issuing nmtui on a ssh console or directly to the server's console. Select Edit a Connection then go go down with the arrow keys and select Set system hostname and there you set the hostname.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.