在 wireshark 中查看 www.google.com
的 DNS 请求,它的十六进制是 03 77 77 77 06 67 6f 6f 67 6c 65 03 63 6f 6d 00
有点困惑,为什么第一个句点是 03
(以及为什么它在那里),第二个句点是 06
,最后一个句点是 03
最佳答案
DNS 协议(protocol)层在RFC 1035 中定义.引用自“3.1. namespace 定义”:
Domain names in messages are expressed in terms of a sequence of labels. Each label is represented as a one octet length field followed by that number of octets. Since every domain name ends with the null label of the root, a domain name is terminated by a length byte of zero.
因此 www.google.com
在 DNS 数据包中被编码为:
03 77 77 77 length 3, "www"
06 67 6f 6f 67 6c 65 length 6, "google"
03 63 6f 6d length 3, "com"
00 length 0 (end of label)
关于networking - 为什么 DNS 请求中句点的十六进制值不是 0x2E,为什么会发生变化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47258547/