LPIC-2 Advanced Networking Configuration Practice Question
Which TWO of the following are valid methods to configure a Linux system to use a specific DNS server for name resolution?
⚠ Common exam trap
Candidates often confuse the role of `/etc/hosts` (static hostname-to-IP mapping) with DNS server configuration, or they think editing `/etc/nsswitch.conf` alone sets the DNS server, when it only defines the lookup 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
✓
Use NetworkManager to set DNS servers for a connection.
NetworkManager provides a centralized way to manage network connections, including DNS settings. When you configure DNS servers via NetworkManager (e.g., using `nmcli` or the GUI), it writes the appropriate `nameserver` lines to `/etc/resolv.conf` (or manages it via its own internal resolver), ensuring the system uses those DNS servers for name resolution. Option E is correct because directly editing `/etc/resolv.conf` and adding a `nameserver` line is the traditional, low-level method to specify DNS servers, which the resolver library reads directly.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Add an entry to /etc/hosts with the DNS server's IP.
Why it's wrong here
/etc/hosts maps hostnames to IPs, not DNS server configuration.
- ✗
Write the DNS server IP to /etc/resolv.conf using systemd-resolved.
Why it's wrong here
systemd-resolved uses its own configuration file, not /etc/resolv.conf.
- ✗
Set the 'hosts' line in /etc/nsswitch.conf to include 'dns'.
Why it's wrong here
nsswitch.conf controls lookup order, not server addresses.
- ✓
Use NetworkManager to set DNS servers for a connection.
Why this is correct
NetworkManager can manage DNS settings dynamically.
- ✓
Edit the /etc/resolv.conf file and add a nameserver line.
Why this is correct
This is the standard method for static DNS configuration.
Visual reference
Go deeper
Related to this question
About these practice questions
This LPIC-2 question is part of Courseiva's 507-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This LPIC-2 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-2 exam.