I have tried this, first is the dns request packet. The second packet is recognized also as a dns request packet. I want the second packet to be a dns response on the first packet
dns = [
IP(src=src, dst=dst) /
UDP(sport=53, dport=2333) /
DNS(id=1, rd=1, qd=DNSQR(qname='www.bittorrent.com')),
IP(dst=src, src=dst) /
UDP(sport=2333, dport=53) /
DNS(id=1,rd=1,tc=0,ra=1,z=1,qdcount=0,ancount=0,nscount=0,arcount=0, qd=DNSQR(qname='www.bittorrent.com',qtype="A",qclass="IN")) / DNSRR(rrname="www.bittorrent.com")
]
wrpcap("test.pcap", dns)
Found some information on GitHub that could be some help with what your asking. This uses the dnslib module.