Courseiva

LPIC-1 Essential System Services and Networking Practice Question

A Linux system's hostname resolution does not consult /etc/hosts before querying DNS. Which file controls the order of name resolution services?

⚠ Common exam trap

Many exam-takers confuse /etc/nsswitch.conf with /etc/resolv.conf or /etc/host.conf, assuming DNS order is controlled by resolver configuration files rather than the NSS database order.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

/etc/nsswitch.conf

The /etc/nsswitch.conf file controls the order of name resolution services by defining the 'hosts' database entry, which specifies the sources (e.g., files, dns) and their lookup order. If the entry is 'hosts: dns files', the system queries DNS before /etc/hosts, bypassing the local file. This file is part of the GNU C Library's Name Service Switch (NSS) framework, which governs all system databases like passwd, group, and hosts.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    /etc/nsswitch.conf

    Why this is correct

    /etc/nsswitch.conf defines the hosts database entry, listing the order in which resolution services such as files, dns and myhostname are consulted. Editing its hosts line restores /etc/hosts precedence before DNS, directly satisfying the stem's requirement to control name resolution ordering.

  • ✗

    /etc/host.conf

    Why it's wrong here

    /etc/host.conf is the legacy glibc resolver file; modern systems using nsswitch.conf ignore it for service ordering, so editing it will not restore /etc/hosts precedence. It is tempting because it historically controlled host resolution order, and remains correct on older libc systems without nsswitch.

  • ✗

    /etc/resolv.conf

    Why it's wrong here

    /etc/resolv.conf lists DNS nameservers and search domains; it does not define the order in which NSS sources such as files and dns are queried. It is tempting because it governs DNS behaviour, but it is the correct file only for specifying which resolver servers to query.

  • ✗

    /etc/dnsmasq.conf

    Why it's wrong here

    /etc/dnsmasq.conf configures the dnsmasq caching forwarder, not the NSS ordering that decides whether /etc/hosts or DNS is consulted first. It is tempting because dnsmasq does handle name resolution, but it would be the correct file only when configuring a local DNS/DHCP forwarder service.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

About these practice questions

Courseiva writes every LPIC-1 question from scratch — 402 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This LPIC-1 practice question is part of Courseiva's free LPI certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LPIC-1 exam.