While I was looking on RFCs of DNS because of implementation to check underscore in CNAME records, I found this interesting discussion and RFC with interesting point:
https://www.ietf.org/mail-archive/web/dnsop/current/msg01449.html
RFC 2181 11. Name syntax: The DNS itself places only one restriction on
the particular labels that can be used to identify resource records.
That one restriction relates to the length of the label and the full
name. The length of any one label is limited to between 1 and 63
octets. A full domain name is limited to 255 octets (including the
separators). The zero length full name is defined as representing the
root of the DNS tree, and is typically written and displayed as ".".
Those restrictions aside, any binary string whatever can be used as the
label of any resource record. Similarly, any binary string can serve as
the value of any record that includes a domain name as some or all of
its value (SOA, NS, MX, PTR, CNAME, and any others that may be added).
Implementations of the DNS protocols must not place any restrictions on
the labels that can be used. In particular, DNS servers must not refuse
to serve a zone because it contains labels that might not be acceptable
to some DNS client programs. A DNS server may be configurable to issue
warnings when loading, or even to refuse to load, a primary zone
containing labels that might be considered questionable, however this
should not happen by default.
So my question is – if I understant it correctly, does it mean, we can use in DNS records like MX, CNAME, etc. something like this?
If we ask for: (imagine there can be any binary string)
the?weird?record,___*-+\k8a#$%...domain.ext
Can this return similar mashup of characters (eg. binary strig?) Is it allowed?
Of course, I am not asking about "hostnames" rules and about "preffered" naming conventions, but about "allowed" use of characters in DNS.
Best Answer
There are three things to consider: