You add the line `10.0.0.9 build.example.com` to /etc/hosts on a test machine, but applications still connect to the public address that DNS returns. /etc/nsswitch.conf contains `hosts: dns files`. What is the correct fix?

LPIC-1 Exam 102-500, objective 109. Networking fundamentals medium

Machine-checked — no person has signed for it. This question was read against the source cited below by an automated pass, which found no contradiction. That is a weaker claim than it sounds: the same kind of process wrote the question, so it can confirm its own mistake.

Treat it as a good draft rather than as settled fact, and read the source below before you rely on it. It is not used in mock exams here — only questions a person has signed for are.

How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.

The options

Correct Change the hosts line in /etc/nsswitch.conf to `hosts: files dns`.

Correct. The sources on a database line are consulted from left to right, and the first one that returns a match ends the lookup. Putting files first makes /etc/hosts authoritative for names it contains.

Not correct Add `nameserver 10.0.0.9` as the first line of /etc/resolv.conf.

Wrong. That would send DNS queries to 10.0.0.9 as if it were a resolver, which it is not. It also does nothing about the order in which files and dns are consulted.

Not correct Move the entry to /etc/host.conf, which takes precedence over /etc/hosts.

Wrong. /etc/host.conf configures the older resolver ordering for programs still using it and holds no host-to-address entries of its own; on a glibc system nsswitch.conf is what decides source order.

Not correct Append `search example.com` to /etc/resolv.conf so the short name is qualified.

Wrong. The search list only completes unqualified names. The name here is already fully qualified, and the problem is source precedence, not qualification.

Why

/etc/nsswitch.conf lists, per database, the sources to consult and the order to consult them in; for the hosts database the usual sources are files (meaning /etc/hosts), dns and, where systemd-resolved is in use, resolve. The list is scanned left to right and a successful lookup stops the scan, so `dns files` means a name that exists in DNS never reaches /etc/hosts. Reversing it to `files dns` is what makes local overrides work.

Where this comes from

Cited
manual page nsswitch.conf(5)

Practise this

Reading one question is not practice. The trainer will draw a short set from objective 109 and space the ones you get wrong.

Practise LPIC-1 Exam 102-500

More questions on this objective

All questions on Networking fundamentals

Practise LPIC-1 Exam 102-500