/etc/nsswitch.conf contains the line `hosts: dns files`, and /etc/hosts maps db.example.com to 10.0.0.5 while public DNS returns 203.0.113.9 for the same name. What does an application using the standard resolver library get?

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

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

Not correct 10.0.0.5, because /etc/hosts always takes priority over DNS

Wrong. /etc/hosts wins only when `files` appears before `dns` on the hosts line, which is the common default but is exactly what has been changed here.

Not correct Both addresses, since the resolver merges every source listed

Wrong. The sources are tried in order and the first one that answers ends the lookup; results are not merged.

Correct 203.0.113.9, because the sources are tried left to right and DNS answers first

Correct. nsswitch.conf lists lookup sources in priority order. With `dns files`, DNS is consulted first and its successful answer ends the search, so the /etc/hosts entry is never reached.

Not correct A lookup failure, because listing dns before files is an invalid configuration

Wrong. Any order of valid sources is legal; the file merely expresses a preference. `dns files` is unusual but perfectly functional.

Why

/etc/nsswitch.conf selects which databases back each kind of lookup and in what order, for example `hosts: files dns myhostname`. Order is the whole point: the first source that returns a result wins, unless an action such as `[NOTFOUND=continue]` overrides that. This is why tools that go straight to DNS, such as dig and host, can disagree with what an application actually resolves, while getent hosts follows nsswitch exactly.

Where this comes from

Cited
LPI exam objective 109.2
What it says
Understand how /etc/nsswitch.conf orders hostname resolution sources.

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