I looked up the man page and couldn't find how long dnsmasq cache a dns. what's the rule for caching and expiration?
I am having a problem that request send to an external service sometimes takes over 5 or 10 seconds for namelookup. I could save the external service ip to /etc/hosts but I am afraid of ip change. Installing Dnsmasq improves name lookup but slow namelookup still happens with less frequency.
One solution is to setup a simple ping in cron job but I need to find out the expiration time first.
thanks.
UPDATE
added dig output
; <<>> DiG 9.8.1-P1 <<>> api.mch.weixin.qq.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45012
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;api.mch.weixin.qq.com. IN A
;; ANSWER SECTION:
api.mch.weixin.qq.com. 0 IN A 140.207.69.102
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Jul 17 19:24:36 2015
;; MSG SIZE rcvd: 55
UPDATE 2
the previous dig output contains TTL as 0 which is misleading. I have posted another dig output.
; <<>> DiG 9.8.1-P1 <<>> api.mch.weixin.qq.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60900
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;api.mch.weixin.qq.com. IN A
;; ANSWER SECTION:
api.mch.weixin.qq.com. 181 IN CNAME forward.qq.com.
forward.qq.com. 181 IN A 101.226.90.149
forward.qq.com. 181 IN A 101.226.129.200
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Jul 21 12:01:54 2015
;; MSG SIZE rcvd: 99
Best Answer
DNSmasq uses the DNS TTL value for determining the caching period. You can use the
dig
command to query the current TTL of your DNS server for that domain.