简体   繁体   中英

sniff with scapy DNS packet from specific IP

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM