wks是已知服务的dns记录,属于RR资源的一种,相对于A记录和AAAA,并不常见
RFC1010是dns中关于wks响应数据的文档。这个文档主要有Protocol Numbers(协议号)和Port Assignments(端口分配表)组成。
在dns的客户端查询类型是wks的时候,在dns服务器的answer段,其中的protocol就是RFC1010中的Assigned Internet Protocol Numbers对应的数值;bits段就是端口号。
关于端口,这里指的是提供网络服务的端口,这个网络服务的网络协议就是Protocol numbers列表中的协议。
在RFC1035中,关于wks的RDATA格式是这样规定的:
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,则表名,第五位是1,udp是11,表示第十一位是1,以此类推。端口分配表从0-255,也就是说最多有256位,32个8字节的char数组,第五位是1,则思0x01;udp则是第十一位是1,即0x00 0x20.