QuestionQ181

Networking

Which of the following lines would be considered valid entries in the file /etc/hosts?

Choose two
  • A 2001:db8::15 www.example.com www
  • B www.example.com www 203.0.13.15
  • C 203.0.113.15 www.example.com www
  • D www.example.com,www 203.0.13.15,2001:db8::15
  • E 2003.0.113.15,2001:db8::15 www.example.com www
Explanation

A valid /etc/hosts entry must begin with a properly formatted IP address (IPv4 or IPv6), followed by one or more hostnames/aliases separated by whitespace (spaces or tabs). Option A (2001:db8::15 www.example.com www) is valid because it starts with a correctly formatted IPv6 address followed by a hostname and an alias separated by spaces. Option C (203.0.113.15 www.example.com www) is valid because it starts with a correctly formatted IPv4 address followed by a hostname and alias separated by spaces. The other options fail: B places the IP address after the hostnames instead of first; D uses commas instead of whitespace as separators, which is not valid syntax; and E contains an invalid IPv4 address (2003.0.113.15, where the first octet exceeds the 0-255 range) combined with improper comma separation.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!