Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Host name allowable characters

Status
Not open for further replies.

CasperTFG

Programmer
Nov 15, 2001
1,210
US
Hey all,

I'm having a heck of a time trying to find this.

What are the allowable characters for a hostname or computername. If anyone knows what the allowable length and allowable characters are it would be appreciated. Or if anyone knows where to find this Info.

Thanks, Craig, mailto:sander@cogeco.ca

Si hoc legere scis, nimis eruditionis habes
 
Another site contained the following in a FAQ section:

What are the valid characters in a hostname?

Hostnames can contain letters, numbers, and hyphens, and may not start with a hyphen. Underscore (_) is not a valid character in a hostname. While there are some DNS server software packages available that allow underscore within published host names, most do not. Using a domain or host name with an underscore will cause most name servers on the Internet to stop recognizing the related host/IP address.

The site reference is:
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Some what, though it is hard to understand. From what I can understand of it I can have a maximum length of 256, but as to what the allowable characters are I am having trouble deciphering the page.

Can anyone understand this?


1. Usage

This character set will be used in places where a domain name is to be specified. It does not govern the specification of internationalised domain names, which are not authorized by the current specification.

2. Definition

The rules for the format and character set of domain names are defined by the following:

dot = %x2E ; "."


alpha = %x41-5A | %x61-7A ; A-Z | a-z


digit = %x30-39 ; 0-9


dash = %x2D ; "–"


dns-char = alpha | digit | dash


id-prefix = alpha | digit


label = id-prefix [*61dns–char id–prefix]


sldn = label dot label ; not to exceed 254 characters


hostname = 1*(label dot) sldn; not to exceed 254 characters

Craig, mailto:sander@cogeco.ca

Si hoc legere scis, nimis eruditionis habes
 
Actually I thin I veared us of course by mentioning Hostname.

What I really want is Windows, Computer name... Here is what I am doing to help get us on track.

I have a program that needs to connect to a host or server machine. The Client program can connect to any specified Computer or server and does this through either a TCP/IP address, eg. 199.0.0.1, or by a windows computer name, such as Computer1.

I need to know the allowable characters for that. Craig, mailto:sander@cogeco.ca

Si hoc legere scis, nimis eruditionis habes
 
This is a BNF specification of a valid host name.
First part are defining characters

dot = %x2E ; "." - This is a Dot (Hex Value and its character
alpha = %x41-5A | %x61-7A ; A-Z | a-z - alpha is a letter Upper or Lower case - hex values followed by printed representation
digit = %x30-39 ; 0-9 - the digits (hex and char)
dash = %x2D ; "–" - The dash (hex and char)

This completes the initial defintions. What we know are that only the 10 digits (0-9) and the 26 letters (upper or lower), the dot and the dash are the only valid characters. The remaining rules then specify how they can be combined.

dns-char = alpha | digit | dash - A dns char can be a letter, a digit, or a dash (but not a dot)
id-prefix = alpha | digit - The id-prefix can only be a letter or a digit
label = id-prefix [*61dns–char id–prefix] - A label is an id-prefix (which we know is either a letter or digit) followed one or more (up to 61) dns-chars (which are letters, digits, or a dash) followed by an id-prefix. What this means is that first and last characters may not be a dash, but you can have dashes in the middle.
sldn = label dot label ; not to exceed 254 characters - The sldn consists of a valid label, followed by a dot followed by another label.
hostname = 1*(label dot) sldn; not to exceed 254 characters - A valid hostname then consists of 1 or more of (label dot) sldn. The (label dot) in optional because its in parens. So a valid hostname at least 1 sldn, but you can have a series (0 or more) of label dot string in front of it, up to a maximum of 254 characters.
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top