XK0-005 · Question #357
XK0-005 Question #357: Real Exam Question with Answer & Explanation
The correct answer is B: MYIP =$(dig pc21.local +norecurse +nocomments). To ensure a script always uses the accurate IP address for a host named pc21.local, the administrator should use the dig command with options to retrieve the IP address from DNS.
Question
A lab virtual image is always named pc21.local and in variety of testing situation. The administrator wants to use the IP address pc21.local in a script but is concerned it may change from day to day, as the image is rebuilt fairly often. Which of the following should the administrator add to a script to ensure the IP address is always accurate?
Options
- AMYIP =$(dig pc21.local +short
- BMYIP =$(dig pc21.local +norecurse +nocomments)
- CMYIP =$(dig pc21.local + answer + mostatus
- DMYIP =$(dig pc21.local +authority)
Explanation
To ensure a script always uses the accurate IP address for a host named pc21.local, the administrator should use the dig command with options to retrieve the IP address from DNS.
Common mistakes.
- A.
+shortis also used for scripting, as it outputs only the RDATA, but+norecurse +nocommentsmight be preferred in some contexts for specific output parsing logic, or if the question implicitly seeks a specific level of detail in the DNS response. - C.
+answerand+mostatusare not standarddigcommand options for controlling output for scripting in this manner. - D.
+authorityonly displays the authority section of the DNS response, which lists authoritative name servers, not the host's A record containing its IP address.
Concept tested. DNS lookup; dig command for scripting
Reference. https://linux.die.net/man/1/dig
Topics
Community Discussion
No community discussion yet for this question.