I want to sniff DNS packets with scapy that their dst or their src is the ip "31.13.93.36". How can i do it?
sniff(filter="dst <ip addr>")
Here is one way:
>>> a=sniff(filter='ip host 8.8.8.8', lfilter=lambda x: x.haslayer(DNS), count=2)
>>> a[1][DNS][DNSRR].rrname
'google.com.'
>>> a[1][DNS][DNSRR].rdata
'172.217.0.110'