Search code examples
pythondnsipv6scapy

DNS Request with Scapy over IPv6


I've seen many examples of how to send DNS requests via Scapy, but none for IPv6. For reference, I'm using Python 3, and ping6 ipv6.google.com is successful for me, so I seem to have a proper gateway. I'm trying to combine https://www.packetlevel.ch/html/scapy/scapyipv6.html and https://thepacketgeek.com/scapy-p-09-scapy-and-dns/, but I'm not sure how to do so exactly (just replacing IP(dst=dst) with IPv6(dst=dst) doesn't work). For reference, I've been trying to resolve "google.com" with Googles DNS Server (https://developers.google.com/speed/public-dns/docs/using).

Edit: I wish to be able to choose the DNS server I reach. For IPv4, I could do so with the following: sr1(IP(dst=dns_dst)/UDP(dport=53)/DNS(rd=1, qd=DNSQR(qname=query_name)))


Solution

    • IPv6 Ping:

      sr1(IPv6(dst="www.google.com")/ICMPv6EchoRequest(),timeout=3)
      

    That would make a simple IPv6 packet with an echo request on top, and send/receive it on level 3

    • DNS over IPv6 on Google's public server, requesting an IPv6 address:

      sr1(IPv6(dst="2001:4860:4860::8888")/UDP()/DNS(qd=DNSQR(qname="www.google.com", qtype="AAAA")))