What is "CACHE.DNS file" in a DNS server?


1. This is related to CACHE.DNS file in a DNS server
2. My questions: (Please FIRSTLY explain it with your own WORDING, and then provide "LINKS" if necessary), i) Where is the DEFAULT LOCATION of the CACHE.DNS file in a DNS server machine?, ii)Could we configure it ?, iii) Could we ADD or DELETE the "input" to this file, and how to do it?, iv) What is the PURPOSE or the FUNCTION of this file? Could we DELETE it  and what is the risk?
3. Thank you

Who is Participating?
DraconianSoulConnect With a Mentor Commented:
flushdns clears the local resolvers dns cache.  jjdurrant has the right syntax to clear the cache.

Assuming you're familier with the concepts of DNS, the cache file is where the DNS server puts a copy of the all the ip addresses it has resolved.  It will keep these entries in the cache flle until the TTL (time to live) expires at which time they are removed the next time a lookup is done and a fresh resolution is retrieved from the internet.  The cache file is also where the root domain servers' IP addresses are kept.

The default location is C:\WINDOWS\system32\dns

There is nothing to configure in the cache file... it is simply a cache.  You could add static entries to it, but windows would not know to preserve them.  If you cleared your cache or if you were trying to redirect traffic from a website to antoher IP, the entry could be overwritten when the TTL on that records expires.

If you're trying to update the root dns entries you should do so through the DNS console.

I beleive if you delete the file, windows will recreate the file next time the service is started.  However, I'm not going to verify that.  You'd be better off not messing with it.
Justin DurrantConnect With a Mentor Sr. Engineer - Windows Server/VirtualizationCommented:
The cache DNS file caches hostnames to speed resolution.. it can be edited with notepad and the cache can be purged via dnscmd /clearcache
authen-techConnect With a Mentor Commented:
All DNS servers have a cache.dns file that contains the IP addresses of all Internet root servers (sometimes called Root Hints).

Purging this file in windows can also (or possibly only) be done using ipconfig /flushdns in a cmd prompt.  

Here's info on it:

I believe the file is located here:
cd %systemroot%\system32\dns

Hope that helps!
ChiefITConnect With a Mentor Commented:
DNS cache is a cache of previously used DNS addresses, and it is stored on the DNS server and on workstations to speed up resolution.

The chronology of a WINS query and DNS query: (how similar they are)
So a client sends out a DNS query:
1) The first place a client looks for is a cached entry. These records could be bad. (To determine if this is the case, go to the command prompt of the client and type IPconfig /flushdns.) (For WINS cach, type NBTstat -rr)
3) Then if your client doesn't have the cached entry, it will look at the client's C:\Windows\system32\drivers\ect\Host file for DNS resolution. (For WINS, you comptuer looks in the C:\Windows\system32\drivers\ect\LMHOST file(You can look at and edit the host file with word pad. Check and see that there are no entries, except local host file in that file for the HOST file and no entries in LMHOST. These files are used if you don't have a DNS server or WINS server respectively. They can be configured to maintain a list of computers you want to contact via a DNS query or WINS query.)

After the client can't determine its own DNS query it will look at the prefered DNS server: (To determine the prefered DNS server, it will be the first on on the list in an IPconfig /all of the client). (For WINS, it will be the preferred WINS server)
1) The first place the server looks for DNS records is its own DNS cache. (You can flush the cash by again going to the command prompt and typing ipconfig /flushdns) (For WINS it you can flush it by purging the Server's WINS cache by using NBTstat -rr)
2) Then the server will look at its own C:\windows\system32\drivers\host file. (for WINS it will be the C:\windows\system32\drivers\LMHOST file
2)Then, the DNS server will have a list of Host A records, Alias records also known as CNAME records and SRV (service)records. (For WINS, it will look at the WINS record, Netbios Alias record, and other server records)
3) If the DNS server can't find the Host A, it will make an attempt to contact an outisde server. There are two types of contacts. One is a recursive and the other is an iteration query. There are also two types of lists to contact the outside server. One is called a forwarder and the other is called roothints.
---brief explaination of each:
---Recursive lookup: A recursive lookup is handled by the server. It will go out to a distant server and try to resolve DNS queries that it can't do on for the client. In other words, if the DNS server can't find an internal address, it will go out to other servers and ask them to look for it. If a resolution is provided. The resolution will be passed down to the client from the server. It is recommended to turn off recursive lookups for security reasons and performance reasons.
--Iteration: Iteration is done when the server can't resolve the query and tells the client, "I can't do it, ask another DNS server." The resolution comes from the remote server, not the local server. So, this is basically passing the buck.
---forwarders: forwarders are manually configured DNS servers that your server will forward queries to if your server can't make the resolution. (most folks configure the ISP's DNS server as the forwarders)
---Root Hints: Root Hints are a list of public DNS servers that your server forwards DNS queries to if your server can't resolve the DNS query

ChiefITConnect With a Mentor Commented:
With that information comes some very powerful DNS troubleshooting skills:

---You can determine the problems of DNS is seconds by asking three questions:
Ask yourself, "is this the only client that is having problems?". If so, it is either the clients DNS cach or Host file that has a bad record.

---Ask yourself, "Are all of my PC's on the domain having problems with this DNS resolution?". If so, then it is probably the server's DNS cache, or Host file with a bad record.

---Ask yourself, "Are all of my PC's having problems getting to ALL outside websites?". If so, you probably have a problem with the configuration of root hints, preferred DNS servers, or forwarders.
Look at DNS cache as a booklet of ever changing business cards. Then, look at host files as a rolladex of internal workstations. And look at DNS servers as a phone book to internal worksations with a link to other phonebooks outside of your domain.

All DNS DOES IS TRANSLATES: fully qualified domain names to IPs and visa-versa. So, there is minimal risk to any of DNS.

Host files can be manually configured in the event that a DNS server is not present. So, there should be NO NEED to edit this. However, this is a need to purge these entries, because with this file configured, it will skip your DNS server and think it can provide its own resolution.

DNS cache is just a bunch of DNS resolutions that were previously made, and it is ever changing. There is NO NEED to ever Edit this. There are times when you might consider purging (let's call it flushing) these records because once in a while you can get a bad DNS record in the cache. Then, your clients once again skip the server for resolution. How do you purge your DNS cache> go to the command prompt and type IPconfig /flushDNS

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.