[GH-ISSUE #345] DNS Client for querying only the cache #453

Open
opened 2026-03-15 22:32:54 +03:00 by kerem · 5 comments
Owner

Originally created by @insanitybit on GitHub (Feb 16, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/345

Would it be possible with this library to query only the local DNS cache? I'd like really fine grained control over when I make the network query vs just the cache - this is for forensic purposes.

Is that currently supported with this library, and if not, could it be?

Originally created by @insanitybit on GitHub (Feb 16, 2018). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/345 Would it be possible with this library to query only the local DNS cache? I'd like really fine grained control over when I make the network query vs just the cache - this is for forensic purposes. Is that currently supported with this library, and if not, could it be?
Author
Owner

@bluejekyll commented on GitHub (Feb 16, 2018):

You might be interested in the Client: https://docs.rs/trust-dns/0.13.0/trust_dns/client/struct.SyncClient.html

That's the synchronous version (possibly easier to get started with), examples are here: https://docs.rs/trust-dns/0.13.0/trust_dns/index.html

With that you can easily specify specifically what host you want to connect to and manually construct the request to just the cache. If the cache respects the option, https://docs.rs/trust-dns/0.13.0/trust_dns/op/struct.Message.html#method.set_recursion_desired, you can set that to false and then the cache may only respond with what is in cache.


btw, the Client will not do any resolution, it just send a message and the you receive a message, so if there is a CNAME in the response, that will not be resolved for you. The Resolver (which will do this) does not currently have easy to use hooks to manipulate the Message options, etc, that you might need.

<!-- gh-comment-id:366104789 --> @bluejekyll commented on GitHub (Feb 16, 2018): You might be interested in the Client: https://docs.rs/trust-dns/0.13.0/trust_dns/client/struct.SyncClient.html That's the synchronous version (possibly easier to get started with), examples are here: https://docs.rs/trust-dns/0.13.0/trust_dns/index.html With that you can easily specify specifically what host you want to connect to and manually construct the request to just the cache. If the cache respects the option, https://docs.rs/trust-dns/0.13.0/trust_dns/op/struct.Message.html#method.set_recursion_desired, you can set that to false and then the cache may only respond with what is in cache. ---- btw, the Client will not do any resolution, it just send a message and the you receive a message, so if there is a CNAME in the response, that will not be resolved for you. The Resolver (which will do this) does not currently have easy to use hooks to manipulate the Message options, etc, that you might need.
Author
Owner

@bluejekyll commented on GitHub (Feb 16, 2018):

Hm, reviewing your question in a little more detail. Are you running a local DNS cache that is queryable on the localhost? What I described would work with such a setup. I haven't tried this, but for example, the mDNSResponder on macOS I think can be queried via localhost:5353. Though, I've never tried!

<!-- gh-comment-id:366106213 --> @bluejekyll commented on GitHub (Feb 16, 2018): Hm, reviewing your question in a little more detail. Are you running a local DNS cache that is queryable on the localhost? What I described would work with such a setup. I haven't tried this, but for example, the mDNSResponder on macOS I think can be queried via localhost:5353. Though, I've never tried!
Author
Owner

@insanitybit commented on GitHub (Feb 16, 2018):

I'd be running on pretty standard Windows/ OSX systems primarily. I didn't know that you could just query the local mDNSResponder, that's very useful to know. I had previously assumed I'd do something equivalent to "DNS_QUERY_CACHE_ONLY" on Windows[0].

https://msdn.microsoft.com/en-us/library/cc982162%28v=VS.85%29.aspx

<!-- gh-comment-id:366110597 --> @insanitybit commented on GitHub (Feb 16, 2018): I'd be running on pretty standard Windows/ OSX systems primarily. I didn't know that you could just query the local mDNSResponder, that's very useful to know. I had previously assumed I'd do something equivalent to "DNS_QUERY_CACHE_ONLY" on Windows[0]. https://msdn.microsoft.com/en-us/library/cc982162%28v=VS.85%29.aspx
Author
Owner

@bluejekyll commented on GitHub (Feb 16, 2018):

That links to system API methods. Just to be clear, this library performs network DNS queries, it does not rely on the Host OS services for any DNS queries...

<!-- gh-comment-id:366112197 --> @bluejekyll commented on GitHub (Feb 16, 2018): That links to system API methods. Just to be clear, this library performs network DNS queries, it does not rely on the Host OS services for any DNS queries...
Author
Owner

@insanitybit commented on GitHub (Feb 16, 2018):

I think I can use it for this based on the mDNSResponder tip. That's sufficient for me. Thanks!

<!-- gh-comment-id:366112616 --> @insanitybit commented on GitHub (Feb 16, 2018): I think I can use it for this based on the mDNSResponder tip. That's sufficient for me. Thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#453
No description provided.