我正在阅读 Windows DNS 服务器调试日志文件,特别是数据包捕获,并试图了解如何解析主机名以便在脚本中使用它们。
以下是答案部分的示例:
Offset = 0x007f, RR count = 2
Name "[C06A](5)e6033(1)g(10)akamaiedge[C059](3)net(0)"
TYPE A (1)
CLASS 1
TTL 20
DLEN 4
DATA 23.62.18.101
因此,查看字符串 "[C06A](5)e6033(1)g(10)akamaiedge[C059](3)net(0)"
我意识到括号中的数字是后面的字符数的计数。将它们全部替换为点(除了第一个和最后一个,应该将其删除)就像一个魅力。
不过,方括号中的内容对我来说仍然是个谜。如果我在处理括号和引号后将其全部删除,则上面的字符串将变为 e6033.g.akamaiedge.net
。这是一个有效的主机名。
所以我的问题是:方括号中的内容实际上意味着什么?将该字符串转换为可以提供给 nslookup 和其他工具的正确主机名的正确方法是什么?
最佳答案
它似乎是 NAME 字段的第二种可能形式,如下所述:
http://www.zytrax.com/books/dns/ch15/#name
NAME This name reflects the QNAME of the question i.e. any may take one of TWO formats. The first format is the label format defined for QNAME above. The second format is a pointer (in the interests of data compression which to fair to the original authors was far more important then than now). A pointer is an unsigned 16-bit value with the following format (the top two bits of 11 indicate the pointer format):
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 1
The offset in octets (bytes) from the start of the whole message. Must point to a label format record to derive name length.
Note: Pointers, if used, terminate names. The name field may consist of a label (or sequence of labels) terminated with a zero length record OR a single pointer OR a label (or label sequence) terminated with a pointer.
其中响应使用指针来引用消息中其他位置的数据。
关于Windows DNS 服务器调试日志主机名格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20381717/