How to flush dns cache or force a refresh?


is there a way to flush dns cache? I used to restart kresd but now it seems to keep its cache.

Best regards,

dunno what version OS you have, but worth quick check: Proposal: keep / preserve kresd dns cache after restart (via config option)

1 Like

Yes, there’s now that option. Router restart also flushes the cache, as it’s in /tmp/ (to save the flash storage).

I found this in /etc/config/resolver:

config resolver 'kresd'
    option keep_cache '0'

is that correct ?

Yes, that seems correct.

Thanks a lot vcunat :slight_smile:

so while you can hard code that setting in the configuration, I find it more useful to be able to flush the cache by hand, as a one-time thing. Turns out this is simple:

# socat - /tmp/kresd/tty/*
> cache.clear()

> ^C

In other words, start the daemon by hand in interactive mode (without -f) and call the cache.clear() function. Other functions are available to do more fine-grained changes but in my experience they often return “error: Function not implemented” so I’m not sure what’s up with that.

1 Like

Sending the command to the running instance seems better than starting yet another one.

BTW, knot-resolver >= 3.0.0 supports more fine-grained cache-clearing, but that version is not in stable Omnia ATM

aaah that’s how you talk to a running kresd. i couldn’t find that in the documentation. :frowning: i’ve updated my answer accordingly.

It’s here in upstream docs (not the best place arguably). The default setup depends on packaging a bit, especially location of the unix socket.

right. i’ve sent a pull request to improve the docs slightly. it would be great to have a standard commandline tool that would just know where that socket is…

There actually is an early prototype of command-line tool for this socket (with tab completion), but we decided to abandon it and do it in a different way in future, in particular to be able to better handle multiple kresd instances at once. Omnia doesn’t package the prototype tool; most distros don’t.

since a recent upgrade, this changed to:

socat - /tmp/kresd/control/*
1 Like