nerdexam
CompTIA

LX0-104 · Question #675

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

The correct answer is D. 127.0.0.1. A correct entry in the /etc/hosts file typically maps an IP address to a hostname, with 127.0.0.1 being the standard loopback IP address for localhost. The /etc/hosts file is used for local DNS resolution before querying external DNS servers.

Networking Fundamentals

Question

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

Options

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

How the community answered

(28 responses)
  • B
    4% (1)
  • C
    4% (1)
  • D
    93% (26)

Why each option

A correct entry in the /etc/hosts file typically maps an IP address to a hostname, with 127.0.0.1 being the standard loopback IP address for `localhost`. The /etc/hosts file is used for local DNS resolution before querying external DNS servers.

Alocalhost

"localhost" is a hostname, not a complete /etc/hosts entry, which requires an IP address mapping.

Blocalhost.localdomain

"localhost.localdomain" is a hostname, not a complete /etc/hosts entry, which requires an IP address mapping.

Clocalhost

"localhost" is a hostname, not a complete /etc/hosts entry, which requires an IP address mapping.

D127.0.0.1Correct

The /etc/hosts file maps IP addresses to hostnames, where `127.0.0.1` is the standard loopback IP address. A complete entry would include this IP followed by hostnames like `localhost` or `localhost.localdomain`, thus `127.0.0.1` is the essential IP component of such an entry.

Elocalhost.localdomain

"localhost.localdomain" is a hostname, not a complete /etc/hosts entry, which requires an IP address mapping.

Concept tested: /etc/hosts file format and loopback IP

Source: https://man7.org/linux/man-pages/man5/hosts.5.html

Topics

#/etc/hosts#Host file format#Localhost mapping

Community Discussion

No community discussion yet for this question.

Full LX0-104 Practice