Benjamin

静以修身,俭以养德,非澹薄无以明志,非宁静无以致远。
随笔 - 397, 文章 - 0, 评论 - 196, 引用 - 0
数据加载中……

dns的wks响应包的rdata如何构建

wks是已知服务的dns记录,属于RR资源的一种,相对于A记录和AAAA,并不常见
RFC1010dns中关于wks响应数据的文档。这个文档主要有Protocol Numbers(协议号)Port Assignments(端口分配表)组成。
dns的客户端查询类型是wks的时候,在dns服务器的answer段,其中的protocol就是RFC1010中的Assigned Internet Protocol Numbers对应的数值;bits段就是端口号。

关于端口,这里指的是提供网络服务的端口,这个网络服务的网络协议就是Protocol numbers列表中的协议。


在RFC1035中,关于wksRDATA格式是这样规定的:

WKS RDATA format

    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

    |                    ADDRESS                   
    | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
   
|       PROTOCOL        |                      
  
 | +--+--+--+--+--+--+--+--+     |

    |                                               |

    /                   <BIT MAP>                   /

    /                                               /
   +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

where:

ADDRESS         An 32 bit Internet address

PROTOCOL        An 8 bit IP protocol number

<BIT MAP>       A variable length bit map. The bit map must be a multiple of 8 bits long.

The WKS record is used to describe the well known services supported by a particular protocol on a particular internet address. The PROTOCOL field specifies an IP protocol number, and the bit map has one bit per port of the specified protocol. The first bit corresponds to port 0, the second to port 1, etc. If the bit map does not include a bit for a protocol of interest, that bit is assumed zero. The appropriate values and mnemonics for ports and protocols are specified in [RFC-1010].

For example, if PROTOCOL=TCP (6), the 26th bit corresponds to TCP port 25 (SMTP). If this bit is set, a SMTP server should be listening on TCP port 25; if zero, SMTP service is not supported on the specified address.

The purpose of WKS RRs is to provide availability information for servers for TCP and UDP. If a server supports both TCP and UDP, or has multiple Internet addresses, then multiple WKS RRs are used.

WKS RRs cause no additional section processing.

In master files, both ports and protocols are expressed using mnemonics or decimal numbers.

BITMAP是多个8 bits;它的数值来源就是RFC1010中的端口分配表,例如st对应的端口是5,则表名,第五位是1udp11,表示第十一位是1,以此类推。端口分配表从0-255,也就是说最多有256位,328字节的char数组,第五位是1,则思0x01udp则是第十一位是1,即0x00 0x20.

posted on 2011-06-08 10:52 Benjamin 阅读(677) 评论(0)  编辑 收藏 引用 所属分类: 杂谈


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理