brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: unbound-control cache_lookup shows what Unbound has cached for a name

Unbound
~/tips/tip-unbound-control-cache-lookup

unbound-control cache_lookup example.com

Prints the cached records and messages Unbound holds for a name, without sending a query.

When DNS gives a strange answer, it is useful to know whether it came from the cache or from upstream. Unbound can show you what it has.

unbound-control cache_lookup example.com

The man page says it prints the RRsets and messages that are in the cache. For every name you list, the content at or under that name is shown. You can give several names separated by spaces.

A related command is lookup:

unbound-control lookup example.com

That prints the name servers Unbound would use to look up the name. Together the two tell you what is cached and where a fresh query would go.

Like all unbound-control commands, it needs control-enable in unbound.conf and the keys from unbound-control-setup. With the +t option you can use tld and root names such as com, but the man page notes that this takes a lot of effort to look up in the cache. Don’t do it on a busy resolver.

When you want to clean up after looking, the same man page lists the flush commands. flush name removes the name from the cache for the types A, AAAA, NS, SOA, CNAME, DNAME, MX, PTR, SRV, NAPTR, SVCB and HTTPS. flush_zone name removes everything at or below the name, and flush_type name type removes one type only. flush_negative removes all negative data, meaning NXDOMAIN, nodata and SERVFAIL answers.

unbound-control flush_type example.com A

Run cache_lookup again afterwards to see that it’s gone. This was not run against a live Unbound; it follows the man page.

Further reading: Unbound docs: unbound-control

Going deeper: Guide: AdGuard Home with Unbound: resolve DNS yourself instead of asking Cloudflare or your ISP

More Unbound tips prefetch: yes unbound-checkconf /etc/unbound/unbound.conf All Unbound tips (3) All topics

Link