txt记录
某个主机名或域名设置的说明
TXT记录,一般指为某个主机名域名设置的说明,用于与别人联系
主要特点
TXT 记录如:
也就是您可以设置 TXT ,以便使别人联系到您
然而也会提升域名邮箱发送外域邮件的成功率,之所以会提升成功率,是因为企业邮箱公司把你的域名加入
白名单,以企业邮箱公司的名义发送邮件,企业邮箱公司不会互相屏蔽的。
----------------------------------------------------------
DNS-SD (Rendezvous) TXT record format
General format rules for DNS TXT records
A DNS TXT record can be up to 65535 (0xFFFF) bytes long. The total length is indicated by the length given in the resource record header in the DNS message. There is no way to tell directly from the data alone how long it is (e.g. there is no length count at the start, or terminating NULL byte at the end).
The format of the data within a DNS TXT record is zero or more strings, packed together in memory without any intervening gaps or padding bytes for word alignment.
The format of each constituent string within the DNS TXT record is a single length byte, followed by 0-255 bytes of text data.
These format rules are defined in Section 3.3.14 of RFC 1035, and are not specific to DNS-SD. DNS-SD simply specifies a usage convention for what data should be stored in those constituent strings.
DNS TXT record format rules for use in DNS-SD (Rendezvous)
The TCP (or UDP) port number of the service, and target host name, are given in the SRV record. This information — target host name and port number — MUST NOT be duplicated using name/value attributes in the TXT record.
The intention of DNS-SD TXT records is convey a small amout of useful additional information about a service. Ideally it SHOULD NOT be necessary for a client to retrieve this additional information before it an usefully establish a connection to the service. For a well-designed TCP-based application protocol, it should be possible, knowing only the host name and port number, to open a connection to that listening process, and then perform version- or feature-negotiation to determine the capabilities of the service instance. For example, when connecting to an AppleShare server over TCP, the client enters into a protocol exchange with the server to determine which version of the AppleShare protocol the server implements, and which optional features or capabilities (if any) are available. For a well-designed application protocol, clients should be able to connect and use the service even if there is no information at all in the TXT record. In this case, the information in the TXT record should be viewed as a performance optimization — when a client discovers many instances of a service, the TXT record allows the client to know some rudimentary information about each instance without having open a TCP connection to each one and interrogate every service instance separately. Extreme care should be taken when doing this to ensure that the information in the TXT record is in agreement with the information retrieved by a client connecting over TCP.
DNS-SD TXT record size
The total size of a typical DNS-SD TXT record is intended to be small — 100 bytes or less.
In cases where more data is justified (e.g. LPR printing), keeping the total size under 400 bytes should allow it to fit in a single standard 512-byte DNS message. (This standard DNS message size is defined in RFC 1035.)
In extreme cases where even this is not enough, keeping size of the TXT record under 1300 bytes should allow it to fit in a single 1500-byte Ethernet packet.
Using TXT records larger than 1300 bytes is NOT RECOMMENDED at this time.
Rules for Names in DNS-SD Name/Value pairs
Spaces in the name are significant, whether leading, trailing, or in the middle — so don't include any spaces unless you really indend that!
If there is no '=', then it is a boolean attribute, and is simply identified as being present, with no value.
When examining a TXT record for a given named attribute, there are therefore four broad categories of result which may be returned:
Attribute not present (Absent)
Unless specified otherwise by a particular DNS-SD (Rendezvous) profile, a given attribute name may appear at most once in a TXT record. If a client receives a TXT record containing the same attribute name more than once, then the client SHOULD silently ignore all but the first occurrence of that attribute. For client implementations that process a DNS-SD TXT record from start to end, placing name/value pairs into a hash table, using the name as the hash table key, this means that if the implementation attempts to add a new name/value pair into the table and finds an entry with the same name already present, then the new entry being added should be silently discarded instead. For client implementations that retrieve name/value pairs by searching the TXT record for the requested name, they should search the TXT record from the start, and simply return the first matching name they find.
Each author defining a DNS-SD (Rendezvous) profile for discovering instances of a particular type of service should define the interpretation of these different kinds of result. For example, for some keys, there may be a natural boolean interpretation:
Absent implies 'false'
Present with no value implies 'true'
For other keys it may be sensible to define other semantics, such as:
Present with emply value implies 'false'. E.g. Not a color printer.
Absent implies 'Unknown'. E.g. A print server connected to some unknown printer where the print server doesn't actually know if the printer does color or not — which gives a very bad user experience and should be avoided wherever possible.
(Note that this is a hypothetical example, not an example of real name/value keys for printing.)
Rules for values in DNS-SD Name/Value pairs
If there is an '=', then everything after the first '=' to the end of the string is the value. The value can contain any eight-bit values including '='. Leading or trailing spaces are part of the value, so don't put them there unless you intend them to be there. Any quotation marks around the value are part of the value, so don't put them there unless you intend them to be part of the value.
The value is opaque binary data. Often the value for a particular attribute will be US-ASCII (or UTF-8) text, but it is legal for a value to be any binary data. For example, if the value of a key is an IPv4 address, that address should simply be stored as four bytes of binary data, not as a variable-length 7-15 byte ASCII string giving the address represented in textual dotted decimal notation.
Generic debugging tools should generally display all attribute values as if they were UTF-8 text, except for attributes where the debugging tool has embedded knowledge that the value is some other kind of data.
Authors defining DNS-SD (Rendezvous) profiles SHOULD NOT convert binary attribute data types into printable text (e.g. using hexadecimal, Base64 or UU encoding) merely for the sake of making the data be printable text when seen in a generic debugging tool. Doing this simply bloats the size of the TXT record, without truly making the data any more understandable to someone looking at it in a generic debugging tool.
Example TXT record containing three name/value pairs
-------------------------------------------------------------------
| 0x0A | name=value | 0x08 | paper=A4 | 0x12 | Rendezvous Is Cool |
-------------------------------------------------------------------
Version tag
Legacy Implementations
Do not assume that all current Apple products using Rendezvous present a model example of how to structure Rendezvous TXT records. Like all companies, Apple sometimes works under severe time pressure, and some of the current Apple Rendezvous products were written in a great hurry. Consequently you should not assume that any particular behaviour of a current Apple Rendezvous product necessarily constitutes an endorsement that that behaviour is correct, or an acceptable model to emulate.
OS X APIs
See SamplemDNSClient.c in the Darwin Open Source Code for simple sample code showing how to do this.
This encoding as C strings means that binary values containing the value 0 or 1 cannot be used with this API. For clients wishing to create binary values in TXT records, the registration can be created with an empty TXT record, and then the DNSServiceRegistrationUpdateRecord call can be used to update the TXT record, as shown below.
DNSServiceRegistrationUpdateRecord(ref, 0, len, buffer, ttl);The buffer passed to this call is used as-is without interpretation or modification, so it is the client's responsibility to ensure that it is a properly formatted DNS TXT record.
Client applications that really really need to obtain raw binary-format TXT records for local multicast Rendezvous names right right now, and can't wait for the OS X update, can embed the Darwin mDNSResponder source code directly in their application, and use that API do do the record lookup. This course of action is recommended only for the very bold (and impatient).
DNS-SD TXT Records for _http._tcp service
http URL
http://{host}:{port}{path}The path key in the TXT record MUST include the leading slash of the abs_path, e.g. the following is a legal DNS-SD TXT record for an _http._tcp service:
-----------------------------google机器翻译-----------------
DNS的的SD (会合) TXT等记录格式
一般格式规则的DNS TXT等记录
1 DNS的TXT等纪录,可达到65535 ( 0xffff )字节长。总长度的长度在DNS信息中给定的头记录资源里。没有办法直接从数据本身判断它有多长(在开始没有记录字符长度或者最后的终止字符是空字符时) 。
该格式的数据在一个DNS的TXT等记录是零或以上的字符串,包装在一起,在记忆,没有任何干预的差距或填充字节为词对齐。
该格式的每个组成字符串内部的DNS TXT等记录,是一个单一的长度字节,然后0-255字节的文本数据。
这些格式规则,是指在第3.3.14的了RFC 1035 ,而并没有特定的DNS -政府统计处。 DNS的可持续发展,根本还明确规定了使用公约哪些数据应存放在这些组成串。
DNS的TXT等记录格式规则的使用在DNS -统计处(会合)
TCP (或UDP )端口号码的服务,并且目标主机名称,是考虑到在srv记录。这一信息-目标主机名称和端口号-绝不能重复使用在文本记录中的名称/值属性。
意图的DNS -统计处TXT等记录,是传达一个小量的有益补充资料服务。最理想的,不应该有必要为客户取回这笔额外资料,然后它是一个有益的建立连接,以提供服务。一个设计良好的TCP基于应用协议的,它应该有可能,只知道主机名称和端口号,打开一个连接,收听过程中,然后再演出版本或功能谈判,以确定能力服务例如。举例来说,当连接到appleshare服务器TCP时,客户签订了协议交换与服务器,以确定哪个版本的appleshare议定书服务器执行的,并且可选的特性或功能(如果有的话)可供选择。一个设计良好的应用协议,客户应能连接上,并使用该服务,因此,即使没有这方面的资料都在上班时间记录。在这种情况下,信息在TXT的记录应被看作是一个性能优化-当客户发现许多一项服务, T XT等记录在案,使客户了解一些最起码的信息,比如每不必打开一个T CP连接,以每一个和审问每个服务实例都分开。极端应注意的时候,这样做是为了确保资料在上班时间纪录,是在协议与信息检索客户端连接在TCP 。
DNS的职务TXT等记录尺寸
警察总人数的一个典型的DNS -统计处TXT等纪录,是打算以小-1 00字节或更少。
的情况下,更多的数据是合理的(如车牌识别打印) ,使总人数为400字节,应该允许它适合在一个单一的标准为512字节的DNS信息。 (此标准的DNS信息,其大小界定了RFC 1035 ) 。
在极端情况下,甚至这样是不够的,保持规模的TXT等记录下1300个字节应该允许它适合在一个单一的1500个字节的以太网包。
利用上班时间记录大于1300个字节,不建议在这个时候。
规则名称在DNS -统计处名称/值对的
位中的名称是显著的,无论是领导,拖尾,或在中间-所以不包括任何空间,除非你真的i ndend。
如果没有' = ' ,那实在是一个布尔属性,并简单地被确定为当前,没有任何价值。
当研究TXT等记录某一特定的命名属性,因此,当局目前4大类的结果,可能会返回:
属性没有出席(缺席)
属性当前,随着空值
除另有规定外,由某一特定的DNS -统计处(会合)简介,给定属性名称可能出现在最一次在TXT记录。如果客户收到TXT等记录含有相同的属性名称,多于一次,那么客户应该默默全部忽略,但第一次发生这种属性。为客户实现这一进程的DNS -统计处TXT等记录从开始到结束,配售名称/值对的一个哈希表,使用化名,因为哈希表的关键,这意味着,如果执行试图加入一个新的名称/值对到表,并认为一个条目具有相同的名字已经存在,那么新入职正补充说:应该悄悄地被丢弃。为客户建置取出名称/值对通过检索TXT等记录被请求的名字,他们应该查找TXT等记录,从一开始,并简单地返回第一个匹配的名字,他们找到。
每个作者确定的DNS -统计处(会合)剖面发现的事例某一特定类型的服务,一定要解释这些不同种的结果。例如,对于某些按键,有可能是一个自然的布尔解释:
缺席意味着'假'
目前没有任何价值,就意味着'真'
对于其他按键,它可以合理界定其他语义,例如:
目前与emply价值,就意味着'假' 。例如:不是彩色打印机。
缺席意味着'不明' 。例如:列印伺服器连接到一些未知的打印机那里打印服务器实际上并不知道如果打印机没有颜色或不-这给人一个极坏的用户体验,并应尽可能避免。
(注:这是一个假设的例子,而不是一个例子,真实姓名/价值按键,可打印) 。
规则的价值观,在DNS的职务名称/值对的
如果存在一个' = ' ,则一切后,第一个' = ' ,以字符串的结尾是价值。该值可以包含任何8位值包括' = ' 。领导或拖尾位部分的价值,所以不要把它们存在,除非你打算在他们那里。任何引号围绕价值的部分的价值,所以不要把它们存在,除非你打算在他们获得部分的价值。
该值是不透明的二进制数据。常值为某一特定属性,将美的ASCII (或对UTF - 8 )文本,但它是合法的一个值为任何的二进制数据。例如,如果值的一个关键,是一个IPv4地址,地址应该简单地被储存了4个字节的二进制数据,而不是作为一个可变长度7-15字节ASCII字符串赋予地址所代表的词句虚线小数点乐谱。
通用调试工具一般应显示出所有属性值,因为如果他们的UTF - 8文本中,除属性那里调试工具嵌入式知识的价值,是一些其他类型的数据。
作者界定的DNS -统计处(会合)概况不应转换成二进制属性的数据类型到打印文本(例如,使用十六进制, base64或UU的编码)仅仅是为了使数据得到打印文本的时候,看到在一个通用的调试工具。这样做,根本bloats大小的TXT等记录,没有真正让数据更可以理解为有人看,它在一个通用的调试工具。
例如TXT等记录包含三个名称/值对的
-------------------------------------------------- --------
| 0x0a |姓名=价值| 0x08 |文件=的A4 | 0x12 | Rendezvous技术是酷|
-------------------------------------------------- --------
版本标签
向后兼容旧的实现,如果必要变更或更新规格随着时间的推移。即使简介作者并没有预料到有必要为今后的任何不相容的变化,有一个版本号码,在规范中提供了有用的保险应不相容的变化成为不可避免的。客户应该忽视TXT等记录一个版本号码更高(或更低) ,比本( ) ,他们知道如何解释。
传统的实现
不要想当然地认为,目前所有的苹果电脑产品采用交会,目前的典范如何构建交会TXT等记录。象所有的公司,苹果电脑,有时作品受到严厉的时间压力,以及目前的一些苹果交会产品写在忙。因此,你不应该假设任何特定行为的,目前苹果交会产品不一定构成背书表示,这种行为是正确的话,还是可以接受的模式来学习的好榜样。
OS X的宣传短片
见samplemdnsclient.c在达尔文开源代码,发现一些简单的样例代码,显示如何做到这一点。
这种编码为C字符串意味着二进制值含有值为0或1 ,不能用这个API 。为客户欲创造二元价值观,在上班时间的记录,登记,可以创造一个空洞TXT等记录在案,然后dnsserviceregistrationupdaterecord ( )的调用,可以用来更新TXT等记录。
dns service registration update record (档号, 0 ,时限,缓冲区,对焦TTL ) ;缓冲区通过了这一号召,是用来作为-是未经解释或修改,所以这是客户端的责任,以确保它是一个正确格式化的DNS TXT等记录在案。
用户端应用程式真的真的需要取得原始二进制格式的TXT等档案,为当地组播交会的姓名权,目前并不能等待,为OS X的更新,可以嵌入达尔文mdnsresponder源代码直接在应用中,并用它的API这样做的记录查找。这一行动是建议只适用于非常大胆(不耐烦) 。
DNS的职务TXT等记录_http._tcp服务
使用方法
如果你是写作的一个工具,以生成一个网址发送给Web浏览器为显示器,那么你应该生成一个网址的形式,其中{主机
http:// {主机} : (港口) {路径}之路关键在上班时间记录必须包括大中华地区领先斜线的abs_path ,例如:以下是一个合法的DNS -统计处上班时间记录为_http._tcp服务:
参考资料
最新修订时间:2024-08-06 15:31
目录
概述
主要特点
参考资料