to /etc/hosts on a CentOS Stream 9 server, an administrator finds that running ping intranet still resolves to 192.168.50.20, the address supplied by the corporate DNS service. The hosts database line in /etc/nsswitch.conf currently reads:
hosts: dns files mdns4
The administrator wants the system to honor the /etc/hosts entry first while still falling back to DNS and Multicast DNS if necessary. Which change will accomplish this goal?
Replace "dns" with "bind4" in the hosts line so it reads: hosts: files bind4 mdns4
Edit /etc/nsswitch.conf so the line reads: hosts: dns mdns4 files
Add the directive "order hosts,bind" to /etc/host.conf and leave nsswitch.conf unchanged
Edit /etc/nsswitch.conf so the line reads: hosts: files dns mdns4
GNU libc's Name Service Switch (NSS) consults the sources listed on the hosts line in /etc/nsswitch.conf from left to right. Placing "files" first makes the resolver check /etc/hosts before querying DNS or mDNS. Editing the existing line to "hosts: files dns mdns4" therefore gives /etc/hosts highest priority but preserves the other lookup methods. Leaving the order as-is, relying on host.conf, or specifying a non-existent source such as "bind4" will not achieve the desired behavior.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the function of /etc/nsswitch.conf in Linux?
Open an interactive chat with Bash
What is the difference between /etc/hosts and DNS in hostname resolution?
Open an interactive chat with Bash
What role does GNU libc's NSS play in hostname resolution?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
System Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access