I’m working on an interface to allow our clients to update their DNS on their own.
I have 2 questions:
- What constitutes valid a valid host and target records? (A, CNAME, MX, TXT) i.e. if the user enters …….. for the host and target the DNS server won’t like that.
- Is there a regex I can use to sanitize user input?
BTW it is BIND9 DNS and C# web app.
Thanks,
Kyle
Domain name labels can technically contain any octet value, but usually they only contain alphanumerics and the hyphen and underscore characters.
This comes from recommendations in section 2.3.1 of RFC 1035:
The underscore character is a more recent addition, typically used in the label portion of
SRVrecords.You could also permit the ‘
.‘ character if you’re going to let users create their own subdomains.The values that are possible are:
Arecord – must be a dotted-quad IP addressCNAMErecord – must be some other legal labelMXrecord – 16-bit integer priority field, and a legal hostname. NB: some people put in labels which themselves point only to aCNAMErecord. This is frowned upon.TXTrecord – anything you like!Note that in every case, if you do allow any of the characters not in the normal set they would need to be escaped if they’re being stored in a BIND format zone file.