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?
Click on the arrows to vote for the correct answer
A. B. C. D.A.
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/networking_guide/sec_configuring_host_names_using_hostnamectlThe correct answer is D. # echo 192.168.1.100 production.company.com >> /etc/hosts.
Explanation: When a system tries to connect to another system on the network, it first looks up the IP address of the system by querying the DNS server. The DNS server returns the IP address associated with the hostname. However, in some cases, it may be necessary to override the hostname that the DNS server returns, for example, when setting up a testing environment.
To override the hostname that the DNS server returns, the administrator can modify the /etc/hosts file on the testing systems. The /etc/hosts file contains a mapping of hostnames to IP addresses, and it takes precedence over DNS.
The command "# echo 192.168.1.100 production.company.com >> /etc/hosts" adds a new entry to the /etc/hosts file that maps the hostname "production.company.com" to the IP address "192.168.1.100". The ">>" operator appends the new entry to the end of the file. This means that any requests to "production.company.com" will be resolved to the IP address "192.168.1.100" on the testing systems.
Option A, "# hostnamectl set-hostname 192.168.1.100 production.company.com", sets the hostname of the system to "production.company.com" and assigns the IP address "192.168.1.100" to it. This command does not override the hostname returned by the DNS server and does not affect the /etc/hosts file.
Option B, "# grep "i IP ${ip addr show} production.company.com > /etc/resolv.conf", attempts to add the IP address of the testing server to the resolv.conf file. This command is incorrect because the syntax is invalid and it would not achieve the desired result of overriding the hostname returned by the DNS server.
Option C, "# ip addr add 192.168.1.100/24 dev eth0 && rndc reload production.company.com", adds a new IP address to the eth0 interface and reloads the DNS configuration using the "rndc" command. This command does not override the hostname returned by the DNS server and does not affect the /etc/hosts file.