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
  • 367
  • 2
  • 11

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
  • 43,252
  • 2
  • 75
  • 122
  • Do you know what causes the entry to change in other VPS? They are the same distro (CentOS 7). Are those changes made by human or software? – MaXi32 Sep 12 '17 at 00:28
  • Actually I like this answer because of the 2nd and third line and mostly the 3rd line said that it has no difference. That straight away answered my question. The manual didn't state about this form.. not sure if this is through testing.. and the person who marked this question. "already found answer" also need to re-read the content of the question not the title. TQ so much again even this is so old – MaXi32 Jul 03 '20 at 07:54