nerdexam
CompTIA

LX0-104 · Question #261

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. Entries in the /etc/hosts file typically follow the format of IP address, followed by the fully qualified domain name (FQDN), and then any aliases for that IP.

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

(20 responses)
  • C
    10% (2)
  • D
    85% (17)
  • E
    5% (1)

Why each option

Entries in the `/etc/hosts` file typically follow the format of IP address, followed by the fully qualified domain name (FQDN), and then any aliases for that IP.

Alocalhost 127.0.0.1 localhost.localdomain

The IP address `127.0.0.1` should precede the hostnames and aliases.

Blocalhost.localdomain localhost 127.0.0.1

The IP address `127.0.0.1` should precede the hostnames and aliases.

Clocalhost localhost.localdomain 127.0.0.1

The IP address `127.0.0.1` should precede the hostnames and aliases.

D127.0.0.1 localhost.localdomain localhostCorrect

The standard format for entries in `/etc/hosts` is `IP-address FQDN alias1 alias2 ...`, meaning the IP address comes first, followed by the canonical hostname, and then any optional aliases.

Elocalhost.localdomain 127.0.0.1 localhost

The IP address `127.0.0.1` should precede the hostnames and aliases.

Concept tested: /etc/hosts file format

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

Topics

#hosts file#DNS resolution

Community Discussion

No community discussion yet for this question.

Full LX0-104 Practice