An entry for buildhost in /etc/hosts is being ignored by dig, which keeps returning NXDOMAIN. Which command resolves the name the same way an ordinary application would, so you can confirm the /etc/hosts entry is effective?

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 nslookup buildhost

Wrong. Like dig, nslookup is a DNS-protocol client. It sends a query to a name server and ignores /etc/hosts and the rest of NSS.

Not correct host buildhost

Wrong. host is also a pure DNS client from the BIND utilities; it will report the name as not found regardless of /etc/hosts.

Not correct dig +short buildhost

Wrong. +short only trims dig's output to the bare answer. It does not change where dig looks, which is still DNS only.

Correct getent hosts buildhost

Correct. getent queries the NSS databases exactly as the C library does, so it walks the hosts line of /etc/nsswitch.conf, including the files source that reads /etc/hosts.

Why

dig, host and nslookup speak DNS directly and deliberately skip /etc/hosts, NSS and any local caching resolver behaviour. getent hosts NAME goes through the same glibc path as ping, ssh and browsers do, which makes it the right tool for the question 'what will an application actually get?'. A disagreement between getent and dig is normally an /etc/hosts entry or an nsswitch ordering, not a DNS fault.

Where this comes from

Cited
LPI exam objective 109.2
What it says
Query hostname resolution with host, dig and getent.

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