How long does dnsmasq cache dns?

Solution 1:

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.

Solution 2:

The option you will need to set for dnsmasq is --min-cache-ttl, the value is in seconds.

According to the dig output, the TTL is 0, if you set this to, say --min-cache-ttl=600, then the TTL value which will be returned by dig will be 600. The TTL for api.mch.weixin.qq.com from where I am is 600, so setting it to 600 seconds yourself should be reasonably safe in avoiding missing any IP changes. (I'm guessing you are located in China.)

This will cause all DNS records to be considered valid for 10 minutes.

See the dnsmasq mailing list message detailing the introduction of this feature.