The use of the underscore in host names

18,549

Solution 1

What are host names?

Analogous to a school class room where each student has a roll number/id so that he/she is identified, in the class room of Internet (or for that matter any computer network) each device that are in the network needs to be uniquely identified. This is done via a Host Name. Thus hostnames are names that helps in identifying devices in a network.

Hostnames with underscore(_) character.

During the period when the standards were being laid for the valid and invalid hostnames, the common terminal interface was the keyboard of the Teletype (TTY) ASR-33. Now this keyborad never had a underscore(_) key in it (check this pic http://www.pdp8.net/asr33/pics/kbd_top.shtml?large) and hence it was not possible to have a hostname with an underscore(_) in it. Check this link for more details: http://www.quora.com/Domain-Name-System-DNS/Why-are-underscores-not-allowed-in-DNS-host-names

Underscore(_) character can be used in the domain names. As this post states Can (domain name) subdomains have an underscore "_" in it? it is completely valid to have an underscore. Some examples(as shown in the post) are _jabber._tcp.gmail.com or _sip._udp.apnic.net. Another example of usage of an underscore is seen here http://ideaharbor.org/notes/technical/enabling-chat-outside-google-apps. Though its valid to use underscores it not a recommended practice.

The wikipedia link in your post states that Microsoft Windows and Android smartphones does not enforce the rule against using an underscore in hostnames. Non enforcement of this rule may result in problems because many systems reject such kind of hostnames.

Hope you get something out of this explanation.

EDIT

On further investigation on the issue, I came upon this wonderful post which I suppose clarifies the usage of underscore in hostnames:

http://networkadminkb.com/KB/a156/windows-2003-dns-and-the-underscore.aspx

Solution 2

Your reading of the Wikipedia page is incorrect. It does not say that those systems use underscores, it says that they support underscores.

If the administrator of such a system was to use an underscore when configuring it then it's his own fault when it fails to interoperate with the rest of the world.

Solution 3

Hostnames (including the domain component(s)) are only allowed to contain alphabetic characters, numeric characters, hyphen and period. This was originally specified in RFC 952 and updated in RFC 1123. The wikipedia article linked in the question says that Android and Windows allow the use of hostnames which violate this syntax.

Such names are definitely invalid hostnames but they are explicitly valid DNS records, even if they are address records which typically contain hostnames. I don't know of an example of a hostname in the wild which uses underscores. Why is this allowed? As explained in the "Name Syntax" section of RFC 2181, DNS intended to be a generic naming service so it doesn't try to enforce all the different name syntaxes that might apply to individual record types.

So even though underscores are disallowed in hostnames, the question of whether a program should allow them is more subtle. In the context of DNS, underscores MUST be allowed. If you are setting the hostname of a particular machine, they should definitely be disallowed because they are invalid. If you are using a hostname, say to access a URL, I guess you could argue that you should allow it if it resolves, in an effort to "be liberal in what you accept".

Solution 4

There is this list from the WayBack machine, but it may not be accurate any more.

And for Configuring Domain Name System (DNS) servers.

Solution 5

hostnames are the {fully qualified} names used in (usually DNS) name resolution. The underscore whilst apparently allowed does not conform to the appropriate rfc regarding allowable characters and could raise incompatibility issues if used outside the local environment.

Perhaps Windows has this as a Netbios/Netbeui hangover from the 90's.

Share:
18,549
rook
Author by

rook

The only way to prove the security of anything is through rigorous testing. There are very smart people on SO and there are excellent answers given, although the right answer isn't always chosen, and the question could be oversimplified or misunderstood. I have been writing exploit code for a while. I have found numerous vulnerabilities in applications and critical infrastructure. I have received three severity metrics from the Department of Homeland Security. The most severe was in the top 500 more dangerous software flaws of all time. My CVE numbers: CVE-2011-0050 CVE-2011-0049 CVE-2011-0048 CVE-2009-1759 CVE-2009-0468 CVE-2009-0467 CVE-2009-0389 CVE-2008-6975 CVE-2008-6499 CVE-2008-6498 CVE-2008-5621 CVE-2008-2043 CVE-2008-2002 CVE-2007-6485 CVE-2007-6458 CVE-2007-6459 CVE-2007-6471 CVE-2007-5646 CVE-2007-0134 CVE-2007-0132 CVE-2007-0130 CVE-2006-6781 CVE-2006-6780 CVE-2006-3208 CVE-2006-3207 CVE-2006-3206 CVE-2006-3205 CVE-2006-3204 CVE-2006-3203

Updated on July 26, 2022

Comments

  • rook
    rook almost 2 years

    Wikipedia states that underscores are used by both Android and Microsoft Windows Systems in hostnames. My question is, what are these host names? Do you have examples of these strange hostnames names and what they are used for?

  • rook
    rook almost 12 years
    Do you know of any windows specific usages of the _ in host names? I feel like some M$ magic might also use this feature.
  • Alnitak
    Alnitak almost 12 years
    re: that link - there's some question as to whether RFC 2181 actually does apply to hostnames. I know one of the authors and am awaiting his response.
  • John Watts
    John Watts almost 12 years
    I realize that many of these points were made in other answers, but I didn't see any that synthesize these or that focus clearly enough on the distinction between a valid domain name in DNS and a valid hostname.
  • rook
    rook almost 12 years
    the way back machine list is dashes not underscores.
  • Sean Kinsey
    Sean Kinsey almost 12 years
    This is actually not correct - it is allowed to have _ in DNS records, but not in hostnames - that some DNS records represent hostnames (A, CNAME) does not mean that all do (_jabber, _tcp). Most major frameworks will not allow _ in hostnames, including .Net, Java, Ruby, Zend PHP and more.
  • user1145101
    user1145101 over 2 years
    The networkadminkb link is broken. This wayback machine link does work as an alternative: web.archive.org/web/20130504144642/http://networkadminkb.com‌​/KB/…