Difficulty: Medium
Correct Answer: 255
Explanation:
Introduction:
HOSTS files map IP addresses to host names locally. Understanding name length constraints helps avoid invalid entries that resolvers may ignore or mishandle.
Given Data / Assumptions:
Concept / Approach:
DNS rules set a maximum FQDN length of 255 characters (including dots). Individual labels between dots are typically limited to 63 characters. While OS parsing may vary, these canonical limits are widely observed in tools and libraries used by operating systems.
Step-by-Step Solution:
1) Consider that HOSTS entries mirror DNS names.2) Apply DNS FQDN limit: up to 255 characters.3) Ensure each label is ≤63 characters to maintain compatibility.
Verification / Alternative check:
RFC-aligned resolvers and libraries commonly enforce these constraints. Empirically, overly long names fail resolution or are truncated, which effectively enforces the 255-character boundary.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing per-label and total-length constraints. Ensure both are met: total ≤255, each label ≤63, and allowed characters only (letters, digits, hyphen) with labels not starting/ending with a hyphen.
Final Answer:
255
Discussion & Comments