CompTIA Linux+ (XK0-004) — Question 31
A Linux administrator is setting up a testing environment and needs to connect to a separate testing server using the production server name. The administrator needs to override the hostname that the DNS is returning in order to use the test environment. Which of the following commands should be run on each of the testing systems to BEST meet this goal?
Answer options
- A. # hostnamectl set-hostname ג€192.168.1.100 production.company.comג€
- B. # grep ג€"i IP ג€${ip addr show} production.company.comג€ > /etc/resolv.conf
- C. # ip addr add 192.168.1.100/24 dev eth0 && rndc reload production.company.com
- D. # echo ג€192.168.1.100 production.company.comג€ >> /etc/hosts
Correct answer: D
Explanation
The correct answer is D because adding an entry to the /etc/hosts file allows the system to resolve the hostname 'production.company.com' to the specified IP address '192.168.1.100', effectively overriding DNS. Option A incorrectly attempts to set the hostname rather than resolve it, option B tries to manipulate resolv.conf which is not relevant in this context, and option C focuses on IP address configuration instead of hostname resolution.