nerdexam
LPI

102-500 · Question #31

Which of the following looks like a correct entry in the /etc/hosts file?

The correct answer is D. 127.0.0.1 localhost.localdomain localhost. D is correct because /etc/hosts entries always follow the format IP_address hostname [aliases...] - the IP address must come first, followed by the canonical hostname and any aliases. Option D (127.0.0.1 localhost.localdomain localhost) matches this structure exactly. Why the…

Networking Fundamentals

Question

Which of the following looks like a correct entry in the /etc/hosts file?

Options

  • Alocalhost 127.0.0.1 localhost.localdomain
  • Blocalhost.localdomain localhost 127.0.0.1
  • Clocalhost localhost.localdomain 127.0.0.1
  • D127.0.0.1 localhost.localdomain localhost
  • Elocalhost.localdomain 127.0.0.1 localhost

How the community answered

(28 responses)
  • A
    4% (1)
  • C
    4% (1)
  • D
    82% (23)
  • E
    11% (3)

Explanation

D is correct because /etc/hosts entries always follow the format IP_address hostname [aliases...] - the IP address must come first, followed by the canonical hostname and any aliases. Option D (127.0.0.1 localhost.localdomain localhost) matches this structure exactly.

Why the others are wrong: A, B, C, and E all place a hostname (either localhost or localhost.localdomain) before the IP address, which is the opposite of the required order - the system parser expects to read an IP first and will fail or misinterpret entries that don't start with one.

Memory tip: Think of it as "address before name" - just like writing a mailing address puts the zip code or country after the street, but in /etc/hosts you lead with the numeric address (IP), then follow with human-readable names. If it doesn't start with digits, it's wrong.

Topics

#hosts file format#hostname resolution#loopback address#network configuration

Community Discussion

No community discussion yet for this question.

Full 102-500 Practice