flush dns cache

General support questions
Post Reply
pAtwall
Posts: 2
Joined: 2016/11/16 10:53:21

flush dns cache

Post by pAtwall » 2016/11/16 11:31:13

Ho can I flush the DNS cache of my CentOS 7 server?

tried

Code: Select all

service nscd restart
and

Code: Select all

/etc/init.d/bind restart
to no avail ( got No such file or directory. type errors - so i imagine that the cache daemon is neither nscd nor bind, i guess a further question would be what is the default dns cache daemon in CentOS 7?)

cheers,
Pierre

User avatar
TrevorH
Site Admin
Posts: 33221
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: flush dns cache

Post by TrevorH » 2016/11/16 12:15:36

Are you running your own DNS server? If not then there probably is no cache that you can flush. What do you have in /etc/resolv.conf?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

scottro
Forum Moderator
Posts: 2556
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

Re: flush dns cache

Post by scottro » 2016/11/16 12:25:41

On CentOS-7.x one uses systemctl restart <whatever>service.

As far as I can see from my own machine, it seems that the dnsmasq.service may be enabled by default. So, you can try

systemctl restart dnsmasq.service

To see what services are running you can use ls /etc/systemd/sysetem/*.wants


However, a lot of times it turns out to be an issue with your name servers, so, also answer Trevor's question. (If your nameserver is the one provided by your ISP, it may be doing something odd, and many people use google's name servers, opendns, or the like).
New users should check the FAQ and Read Me First pages

pAtwall
Posts: 2
Joined: 2016/11/16 10:53:21

Re: flush dns cache

Post by pAtwall » 2016/11/16 12:38:49

Not running my own DNS server.

Not much in /etc/resolv.conf:

Code: Select all

# Generated by NetworkManager
search {my company name}
nameserver 8.8.8.8
nameserver 8.8.4.4
and

Code: Select all

/etc/systemd/sysetem/*.wants
returns -bash: /etc/systemd/sysetem/*.wants: No such file or directory

I also tried what is recommended here:
http://serverfault.com/questions/500176 ... appen-then
and it looks like no caching is happening at all?

Code: Select all

[root@localhost ~]# dig ohdns.org | grep sec
;; Query time: 144 msec
[root@localhost ~]# dig ohdns.org | grep sec
;; Query time: 146 msec
[root@localhost ~]# dig ohdns.org | grep sec
;; Query time: 21 msec
[root@localhost ~]# dig ohdns.org | grep sec
;; Query time: 198 msec
[root@localhost ~]# dig ohdns.org | grep sec
;; Query time: 12 msec
[root@localhost ~]# dig ohdns.org | grep sec
;; Query time: 144 msec
If this is the case, then my problem lies somewhere else - do you think DNS is cached at all?

User avatar
TrevorH
Site Admin
Posts: 33221
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: flush dns cache

Post by TrevorH » 2016/11/16 12:53:06

DNS is not cached except on the DNS server you talk to. There entries are looked up when required and then kept in cache for as long as the TTL on the dns record says to keep them cached for. Since you're using 8.8.8.8 there is no way that you can flush Google's cache for them.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

scottro
Forum Moderator
Posts: 2556
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

Re: flush dns cache

Post by scottro » 2016/11/16 20:01:54

Also, (though as Trevor says, it turns out to not be relevant), I said ls /etc/systemd/system/*.wants. That is, there's an ls, (lower case L) to list what services are expected to start by default.
New users should check the FAQ and Read Me First pages

Metal3d
Posts: 1
Joined: 2017/05/22 22:12:56

Re: flush dns cache

Post by Metal3d » 2017/05/22 22:13:54


Post Reply