I'm working on an interface to allow our clients to update their DNS on their own.
我正在开发一个界面,允许我们的客户自己更新他们的DNS。
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?
什么构成有效的主机和目标记录? (A,CNAME,MX,TXT)即,如果用户为主机输入........并且目标DNS服务器将不喜欢。
有没有我可以用来清理用户输入的正则表达式?
BTW it is BIND9 DNS and C# web app.
顺便说一下,它是BIND9 DNS和C#网络应用程序。
Thanks,
Kyle
3 个解决方案
#1
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:
这来自RFC 1035第2.3.1节中的建议:
The labels must follow the rules for ARPANET host names. They must start with a letter, end with a letter or digit, and have as interior characters only letters, digits, and hyphen. There are also some restrictions on the length. Labels must be 63 characters or less.
标签必须遵循ARPANET主机名的规则。它们必须以字母开头,以字母或数字结尾,并且内部字符仅包含字母,数字和连字符。长度也有一些限制。标签不得超过63个字符。
The underscore character is a more recent addition, typically used in the label portion of SRV
records.
下划线字符是最近添加的字符,通常用于SRV记录的标签部分。
You could also permit the ".
" character if you're going to let users create their own subdomains.
你也可以允许“。”字符,如果您要让用户创建自己的子域。
The values that are possible are:
可能的值是:
-
A
record - must be a dotted-quad IP address -
CNAME
record - must be some other legal label -
MX
record - 16-bit integer priority field, and a legal hostname. NB: some people put in labels which themselves point only to aCNAME
record. This is frowned upon. -
TXT
record - anything you like!
记录 - 必须是虚线四元组IP地址
CNAME记录 - 必须是其他一些合法标签
MX记录 - 16位整数优先级字段和合法主机名。注意:有些人放入的标签本身只指向CNAME记录。这令人不悦。
TXT记录 - 你喜欢的任何东西!
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.
请注意,在每种情况下,如果您允许任何不在正常集合中的字符,则如果它们存储在BIND格式区域文件中,则需要对其进行转义。
#2
Do not forget AAAA, the IPv6 addresses (remember, only two years left before we run out of IPv4 addresses...).
不要忘记AAAA,IPv6地址(记住,在我们用完IPv4地址之前仅剩两年了......)。
For the legal names, read RFC 1123, section 2.1. domain names can be anything, host names have a much stricter syntax (see RFC 1123).
有关合法名称,请阅读RFC 1123第2.1节。域名可以是任何东西,主机名具有更严格的语法(参见RFC 1123)。
#3
The answer used to be easy, but not anymore.
答案过去很简单,但不再是。
You can use almost any Unicode characters, but they should go thru a normalization, and encoding process.
您几乎可以使用任何Unicode字符,但它们应该通过规范化和编码过程。
See RFC 3490 (IDNA), RFC 3454 (Stringprep), RFC 3491 (Nameprep), RFC 3492 (Punycode)
请参阅RFC 3490(IDNA),RFC 3454(Stringprep),RFC 3491(Nameprep),RFC 3492(Punycode)
Or go with Wikipedia for the big picture (http://en.wikipedia.org/wiki/Internationalized_domain_name).
或者与*一起浏览大图(http://en.wikipedia.org/wiki/Internationalized_domain_name)。
#1
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:
这来自RFC 1035第2.3.1节中的建议:
The labels must follow the rules for ARPANET host names. They must start with a letter, end with a letter or digit, and have as interior characters only letters, digits, and hyphen. There are also some restrictions on the length. Labels must be 63 characters or less.
标签必须遵循ARPANET主机名的规则。它们必须以字母开头,以字母或数字结尾,并且内部字符仅包含字母,数字和连字符。长度也有一些限制。标签不得超过63个字符。
The underscore character is a more recent addition, typically used in the label portion of SRV
records.
下划线字符是最近添加的字符,通常用于SRV记录的标签部分。
You could also permit the ".
" character if you're going to let users create their own subdomains.
你也可以允许“。”字符,如果您要让用户创建自己的子域。
The values that are possible are:
可能的值是:
-
A
record - must be a dotted-quad IP address -
CNAME
record - must be some other legal label -
MX
record - 16-bit integer priority field, and a legal hostname. NB: some people put in labels which themselves point only to aCNAME
record. This is frowned upon. -
TXT
record - anything you like!
记录 - 必须是虚线四元组IP地址
CNAME记录 - 必须是其他一些合法标签
MX记录 - 16位整数优先级字段和合法主机名。注意:有些人放入的标签本身只指向CNAME记录。这令人不悦。
TXT记录 - 你喜欢的任何东西!
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.
请注意,在每种情况下,如果您允许任何不在正常集合中的字符,则如果它们存储在BIND格式区域文件中,则需要对其进行转义。
#2
Do not forget AAAA, the IPv6 addresses (remember, only two years left before we run out of IPv4 addresses...).
不要忘记AAAA,IPv6地址(记住,在我们用完IPv4地址之前仅剩两年了......)。
For the legal names, read RFC 1123, section 2.1. domain names can be anything, host names have a much stricter syntax (see RFC 1123).
有关合法名称,请阅读RFC 1123第2.1节。域名可以是任何东西,主机名具有更严格的语法(参见RFC 1123)。
#3
The answer used to be easy, but not anymore.
答案过去很简单,但不再是。
You can use almost any Unicode characters, but they should go thru a normalization, and encoding process.
您几乎可以使用任何Unicode字符,但它们应该通过规范化和编码过程。
See RFC 3490 (IDNA), RFC 3454 (Stringprep), RFC 3491 (Nameprep), RFC 3492 (Punycode)
请参阅RFC 3490(IDNA),RFC 3454(Stringprep),RFC 3491(Nameprep),RFC 3492(Punycode)
Or go with Wikipedia for the big picture (http://en.wikipedia.org/wiki/Internationalized_domain_name).
或者与*一起浏览大图(http://en.wikipedia.org/wiki/Internationalized_domain_name)。