Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caching DNS using getaddrinfo

I am using system call getaddrinfo() to obtain IP address from DNS.

I will like to know if the cache information is stored on Linux or not?

If the cached information is stored, is it possible to clear the cache information?

I will like to know how to clear the cache information.

Thanks .

like image 921
Ashish Yadav Avatar asked Jul 30 '12 05:07

Ashish Yadav


People also ask

Does getaddrinfo use DNS?

getaddrinfo() uses the DNS protocol to talk to your name servers, which are configured using their IP address.

Can you cache DNS?

DNS caching allows any DNS server or client to locally store the DNS records and re-use them in the future – eliminating the need for new DNS queries. The Domain Name System implements a time-to-live (TTL) on every DNS record. TTL specifies the number of seconds the record can be cached by a DNS client or server.

How do I setup a DNS cache?

Creating a resolver DNS cache Create a resolver cache on the BIG-IP® system when you want the system to resolve DNS queries and cache responses. On the Main tab, click DNS > Caches > Cache List . The DNS Cache List screen opens. Click Create.


1 Answers

In general, no, the glibc resolver does not cache getaddrinfo results.

On systems running nscd, some names may be cached. (At least, gethostbyname may go through cache; I'm not sure about getaddrinfo.) Restart the daemon to clear the cache.

It is usually expected that the upstream (presumably recursive) DNS resolver is performing caching. In most situations, that is outside of your control.

like image 62
ephemient Avatar answered Nov 14 '22 21:11

ephemient