My servers was keep asking similar dns queries to 8.8.8.8 and it cost around 30 ms every time. So that I have installed a Bind server and forwarded all dns requests to 8.8.8.8 like this:
zone "." IN {
type forward;
forward first;
forwarders { 8.8.8.8; };
};
Everything works but I have a problem with caching.
my aim is caching queries' answer like 1 hours.
desired scenario:
-let's say a server send a dns query for google.com
-my bind server forward it to 8.8.8.8 and returns a response and cache it.
-same server or another server send dns request to google.com in 1 hour.
-this time bind dns server don't forward it to 8.8.8.8, instead
, return answer from its own cache. In that way my servers won't lose time to go 8.8.8.8 again and again.
current situation:
-each server gets a response within 30ms on the first query.
-When I send a query again, it returns answers 0 ms. It is probably returning from the local cache on the server.
-but after 1-2 minutes, when I send a query from the same server, the response is still over 30 ms.
-also if I send same dns query(let's say google.com) from 4 different servers in the same seconds, still all servers forwards to 8.8.8.8 and answers come from remote dns servers, not my local cache