Clearing the DNS cache

ron.alan

Active Member
Joined
Dec 24, 2023
Messages
315
Reaction score
231
Credits
2,152
So I wanted to clear my DNS cache and did a search for how to do it. So I found (from here) to run either sudo /etc/init.d/networking restart or sudo service networking restart. When I ran them (I ran both) I got a message that it was deprecated. The exact message on both was:

Running /etc/init.d/networking restart is deprecated because it may not re-enable some interfaces ... (warning).
Reconfiguring network interfaces...done.

So I have two questions: 1) Did one, or both, of these commands work or not? 2) Is there a better way to clear the DNS cache?

I'm on Devuan GNU/Linux 5.
 


I used Devuan some time ago at very early stages of Devuan development so I don't remember which DNS resolver do you have.
You need to find this out.
Anyway here are some options for flushing DNS cache:
NCSD: sudo /etc/init.d/nscd restart
Dnsmasq: sudo /etc/init.d/dnsmasq restart
or
sudo killall -USR1 dnsmasq
then check file size (should be "0" - zero):
tail -f n1000 /var/log/syslog | grep "cache size"
BIND: You may have to try multiple commands:
sudo /etc/init.d/named restart
sudo rndc restart
sudo rndc exec

Hopefully one of these will help
 
So are you saying that what I did didn't clear the DNS cache? What does the line "Reconfiguring network interfaces...done." mean?
How do I find out what resolver I have?

EDIT
So I opened synaptic and searched for "DNS" and of what came from the search, I have bind9-host installed, if this means anything.
 
Last edited:
sudo systemctl restart bind9

If you are using systemd-resolve
sudo resolvectl flush-caches

If you are using an older version of systemd (before v239), use this command instead:
sudo systemd-resolve --flush-caches

 
I have bind9 installed, but when I run systemctl is-active named in the terminal it says it isn't running:

$ systemctl is-active named
ERROR:systemctl:Unit named.service could not be found.
unknown

I also get a negative response for systemd-resolved (obviously), Dnsmasq, and nscd.
 
Last edited:
i use :

sudo /etc/init.d/nscd restart

But it is rare that i have to use it. The last time i used it was because Amazon Prime Video player was having an issue and throwing a 7031 (?) error -- the the recommended fix was to clear/restart the DNS server.
-- Though I dont know why this was an issue, it did in fact clear the trouble.
 
two things:
1) this is ncd not mcd (unless typo here):
sudo rndc restart
sudo rndc exec

so this is r n d c

2) if you don't have DNS running there is nothing to flush.
 
I'm confused. Doesn't there have to be some DNS service running? I thought that was necessary to browse the internet.
No, the dns servers are part of your network configuration for your system. No need to have a caching service running, dns servers however do have a cache, so that they don't need to request something again when another client requests the same as a previous client, which is where TTL comes from in dns records.
 
No, the dns servers are part of your network configuration for your system.
There do exist caching services which you can run on your client from what I remember from a topic but you will have to install it yourself. And if you are using systemd-resolved could be that it has some caching thing integrated into it but from what I remember you are running a distribution that doesn't use systemd. For example.
Code:
dnsconfd : Local DNS cache configuration daemon
 
Since you are using Devuan you do not need to flush the DNS Cache it does not cache DNS lookups - depending if you installed it with SysVInit or RunIt - since there is no systemd any systemd commands will not work such as systemctl
You router may cache them but all non-systemd Linux OSes do not DNS cache as far as I know
 
Since you are using Devuan you do not need to flush the DNS Cache it does not cache DNS lookups - depending if you installed it with SysVInit or RunIt - since there is no systemd any systemd commands will not work such as systemctl
You router may cache them but all non-systemd Linux OSes do not DNS cache as far as I know

Does this mean that you should also clear the DNS in the router?
 

Members online


Top