Hostnames, Domain names, and “Official” host names
Tuesday, January 16th, 2007Due to regular arguments I’ve had with people about this I thought I should document this somewhere for people to see:
Host names
The syntax for a hostname was defined waay back in RFC 952. it’s defined as:
<hname> ::= <name>*["."<name>]
<name> ::= <let>[*[<let-or-digit-or-hyphen>]<let-or-digit>]
(if you prefer as a regex /[a-z]([a-z0-9-]*[a-z0-9])?(\.[a-z]([a-z0-9-]*[a-z0-9])?)*/.)
RFC 952 also says a computer has an “official” hostname and zero or more “nicknames” or aliases, but are discouraged.
Domain names
A domain name is something that’s in DNS. A Domain name is much less strict on what it allows. This is used in RFC 2782 to avoid collisions with hostnames by requiring that SRV records have a “_” prepended to them since no valid hostname can have a _.
Implications
Other premsises:
- RFC 821 says in section 3.7:
Whenever domain names are used in SMTP only the official names are used, the use of nicknames or aliases is not allowed. - RFC 1123 says:
5.2.5 HELO Command: The sender-SMTP MUST ensure that the <domain> parameter in a HELO command is a valid principal host domain name for the client host. - RFC 2181 Section 10.3:
[...] Thus, if an alias is used as the value of an NS or MX record, no address will be returned with the NS or MX value. This can cause extra queries, and extra network burden, on every query. It is trivial for the DNS administrator to avoid this by resolving the alias and placing the canonical name directly in the affected record just once when it is updated or installed. - RFC 2821 Section 4.3.1
Note: all the greeting-type replies have the official name (the fully-qualified primary domain name) of the server host as the first word following the reply code.
Therefore:
- You cannot have a “_” in your HELO/EHLO. Even tho microsoft windows machines love to do this. Expect your mail to be dropped.
- MX’s should point to the “official” (canonical) name of the mail server, which should in theory be the same as the name produced in the 220 banner.
Updated: With Aristotles fixed regex. Ooops! My bad.