Domanda

As I noticed class from google library com.google.common.net.InternetDomainName containts the following constant:

private static final int MAX_LENGTH = 253;

Code below, checks length during creation of InternetDomainName instance:

 checkArgument(name.length() <= MAX_LENGTH, "Domain name too long: '%s':", name);

But RFC-2181 says that:

A full domain name is limited to 255 octets (including the separators).

So, what is valid max length for domain name?

È stato utile?

Soluzione

This is straight from wikipedia:

The full domain name may not exceed the length of 253 characters in its textual representation. In the internal binary representation of the DNS the maximum length requires 255 octets of storage, since it also stores the length of the name.

And this is from RFC 1035:

Each label is represented as a one octet length field followed by that number of octets. Since every domain name ends with the null label of the root, a domain name is terminated by a length byte of zero.

Altri suggerimenti

TLDR

If you just want to use the domain as a website, the limit is: 255 characters.

If you just want to use the domain with email, the limit is: 253 characters.

Source - As a Website

RFC2821 (April 2001) established the 255-character limit on domains and RFC5321 (October 2008) retained this standard. To quote both of them...

4.5.3.1.2. Domain

The maximum total length of a domain name or number is 255 characters.

Source - For Emails

An email address must be in the form of a@example.com, based on what we see from RFC821 (August 1982). The to field in SMTP cannot exceed 255 characters. The shortest possible local-part, a, is one character, @ is one character, which leaves only 253 characters remaining for a domain.

As per RFC1123 Section 2.1, Host software MUST handle host names of up to 63 characters and SHOULD handle host names of up to 255 characters; which means it should be able to accept and process host names of any length up to 63 characters without issue, and should be able to accept and process host names of up to 255 characters if possible.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top