Valid hostname characters?

What are valid hostname characters? It will be something like a network computer or a web domain.

To put this in context, I am writing a computer game that connects to a remote server; so I have a field for the host name and a field for the port. Obviously, the port is a number in the short range, but I need to know what all possible host characters (and any other pattern that may be required), do I need to start the host name with a letter?).

Examples of hostnames include localhost or google.com .

+67
networking
Aug 19 2018-10-19
source share
3 answers

Complete this wiki , in particular the Limitations on valid hostnames section.

Host names consist of a series of labels connected by dots, like all domain names. For example, "en.wikipedia.org" is the host name. Each label must be between 1 and 63 characters long, and the full host name (including separator points, but not the endpoint) can contain a maximum of 253 ASCII characters.

Internet standards (comment requests) for protocols require that component host name labels contain only ASCII letters from “a” to “z” (case insensitive), numbers from “0” to “9”, and hyphens ('-' ) The original hostname specification in RFC 952 required labels to not begin with a digit or a hyphen and should not end with a hyphen. However, the subsequent specification ( RFC 1123 ) allowed hostname labels to begin with numbers. Other characters, punctuation, and spaces are not allowed.

+73
Aug 19 '10 at 2:58 p.m.
source share

It depends on whether you process the IDN before or after the IDN toASCII algorithm. (that is, you see the domain name παράδειγμα.δοκιμή as παράδειγμα.δοκιμή or as xn--hxajbheg2az3al.xn--jxalpdlp

In the latter case, when you process an IDN through punycode, the old RFC 1123 rules apply:

U + 0041 through U + 005A (AZ), U + 0061 through U + 007A (az), collapsed with each other, U + 0030 through U + 0039 (0-9) and U + 002D (-). [edit: and U + 002E (.) of course; rules for tags allow others, with dots between tags, sometimes these are obvious bits that are easiest to forget]

If you see it in IDN form, the valid characters are very diverse, see http://unicode.org/reports/tr36/idn-chars.html for a convenient diagram of all valid characters.

Most likely, your network code will handle punycode, but your display code (or even just pass lines to other layers and from other layers) with a more readable form, since no one starts the server on السعودية. domain wants to see their server listed as being on .xn - mgberp4a5d4ar

+19
Aug 19 '10 at 15:15
source share

A "name" (network, host, gateway or domain name) is a text string up to 24 characters long, taken from the alphabet (AZ), numbers (0-9), minus sign (-) and period (.). Please note that periods are only allowed when they are used to distinguish between domain name component names. (See RFC-921, “Domain Name System Implementation Schedule,” for background). No blank or white space characters are allowed as part of the name. There is no difference between upper and lower case. The first character must be an alpha character. The last character must not be a minus sign or a period. A host that performs the GATEWAY function must have "-GATEWAY" or "-GW" as part of its name. Hosts that are not Internet gateways should not use "-GATEWAY" and "-GW" as part of their names. A host that is TAC must have a “-TAC” as the last part of its host name, if it is a DoD host. Single character names or aliases are not allowed.

This is stated at http://support.microsoft.com/kb/149044

+3
Jul 31 '14 at 9:28
source share



All Articles