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:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Command hostname
returns:
myproject.localdomain
hostname -f
returns:
localhost
domainname returns (none)
Do I have to choose a real domain purchased and prepend to it the hostname like this:
ip hotname.domainame hostname
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:
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.