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.
More questions on this objective
- A subnet is defined as 192.168.10.0/26. How many addresses in it can actually be assigned to hosts? machine-checked
- A host is configured with the address 172.20.35.77/20. What is the network address of its subnet? machine-checked
- In IPv6, which address is the loopback address, equivalent in role to 127.0.0.1 in IPv4? machine-checked
- Which is the correct fully compressed form of the IPv6 address 2001:0db8:0000:0000:0000:ff00:0042:8329? machine-checked
- Which pairing of a service with its default port number is correct? machine-checked
- DNS normally uses UDP port 53. In which situation does a DNS client or server fall back to TCP on port 53? machine-checked