0

First, I know how to declare FQDN but, I just want to know are they the same thing:

I have 2 VPSs running using Centos 7. When I look up at the /etc/hosts file:

I found the entry of the host file for VPS 1 like this:

127.0.0.1 localhost.localdomain localhost

But then the entry of host file for VPS 2 is like this:

127.0.0.1 localhost localhost.localdomain

I'm not sure why the 2 entries are different. My question is, what is the correct syntax for declaring this Fully Qualified Domain Name in your host file? Are those 2 lines can be used and has the same purpose?

Edit:

About the mark as duplicated answer, for explanation: The question asked there specifically about RHEL-based and Debian-based distros that have difference host setting but this question is about the same distro (CentOS 7) but has different host setting that might confuse some questioners to get the 'why' answer where the answer from the reference doesn't cover this.

MaXi32
  • 387

1 Answers1

4

Even when your environment doesn't have man pages installed it doesn't mean you don't have access to them, either by installing them with yum install man-pages man or using online versions e.g. from man.he.net, man7.org. or linux.die.net.

The format is IP_address canonical_hostname [aliases...]. Therefore:

  • 198.51.100.10 host.example.com host is correct, as it has the FQDN (only without .) first
  • 127.0.0.1 localhost.localdomain localhost would be closest to that form
  • 127.0.0.1 localhost localhost.localdomain does the same, no any practical difference
  • 127.0.0.1 localhost would probably be just as sufficient.
Esa Jokinen
  • 52,963
  • 3
  • 95
  • 151