Capturing dns packages using java

I want to register visited websites in the system. Therefore, I decided to write packets sent by the system. I am using the Jpcap API. I can write a lot of packages. Now, what I want to do, I want to filter only DNS packets. I think it will be possible to register websites.

I need a way to filter DNS packets. How can i do this?

+3
source share
3 answers

I found that it easily handles all packets in port 53, so I used this filter

udp dst port 53

tanx jack for ur prompt

0
source

It says here

. Ethereal/Wireshark

, ,

captor.setFilter("dns", true);

0

One more ugly approach is to scan port 53 for UDP. However, the previous answer seems more understandable in terms of implementation.

0
source

Source: https://habr.com/ru/post/1742926/


All Articles