Reputation: 111
My question stems from this process: Assume an application has a host or address field and would like to connect to some service at that address. Many applications will look at that address and guess if it is an ip address or a host name. This application may use a function like inet_pton() to do this checking. If the address does look like an ip address, the application would not perform a DNS lookup and use that ip address directly.
Now, I am not suggesting this is a good idea but what if some one defined a dns name that looked like 1.2.3.4. That looks like an ip address so the application above would use that as and ip address and not as a DNS name.
From observation, it seems most applications behave as described in the first paragraph. Which seems beneficial for a few reasons to me. Is there any documentation that states that DNS names that look like IP addresses should not be used. Or any documentation that says that even if some one defined a DNS name to look like an IP address it is OK to not honor it as such.
Upvotes: 2
Views: 2683
Reputation: 13196
Others have answered already but I'll add and consolidate.
Relevant RFCs:
Originally, a hostname could not begin with a number, to disambiguate between hostnames and IP addresses. In the revision, that was changed, and hostnames can begin with a number. Thus, domain names like 127.0.0.1.com are legal. TLDs cannot begin with a number (TLD stands for top level domain, of which .com, .net, .org, country codes, and others are members). Names must contain at least one character, must begin and end with alphanumeric characters, and may freely be up to 64 characters long (though the standard supports longer hostnames, systems are not required to support names longer than 64 characters).
Additionally, as described in the final RFC, some SLDs and TLDs are reserved and cannot be registered.
Upvotes: 6
Reputation: 73966
The relevant specification to look at is Section 2.1 of RFC 1123:
If a dotted-decimal number can be entered without such identifying delimiters, then a full syntactic check must be made, because a segment of a host domain name is now allowed to begin with a digit and could legally be entirely numeric (see Section 6.1.2.4). However, a valid host name can never have the dotted-decimal form #.#.#.#, since at least the highest-level component label will be alphabetic.
Upvotes: 3