I noticed this setting in the man page for dnsmasq:
--host-record=[,....],[],[][,]
Add A, AAAA and PTR records to the DNS. This adds one or more names to the DNS with associated IPv4 (A) and IPv6 (AAAA) records. A name may appear in more than one --host-record and therefore be assigned more than one address. Only the first address creates a PTR record linking the address to the name. This is the same rule as is used reading hosts-files. --host-record options are considered to be read before host-files, so a name appearing there inhibits PTR-record creation if it appears in hosts-file also. Unlike hosts-files, names are not expanded, even when --expand-hosts is in effect. Short and long names may appear in the same --host-record, eg. --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100
If the time-to-live is given, it overrides the default, which is zero or the value of --local-ttl . The value is a positive integer and gives the time-to-live in seconds.
The last sentence seemed to offer hope.
So I tried making the file /etc/dnsmasq.d/50-hosts.conf: host-record=www.mikrotik.com,159.148.147.196,3600
..hoping and half-expecting it to work, but it didn't work. I am still getting the constant requests coming from the router.
Is there any way of getting this to work? Is this option supported by pihole-FTL?
Have you blocked this domain? The TTL of 2 seconds applies only to blocked or locally served domains. For that specific domain, the TTL provided by the nameserver is 7200 seconds.
How come you got the full 7200 value? I always get how many seconds are left to live when I use dig.
Anyway, no the domain is not blocked (I double checked), but if only blocked domains have the local TTL of 2 seconds, how come this is a problem for the people in the previous discussion? Change the TTL? - #23 by lug-gh
It seems to me that their problem is not related to local-ttl at all, but rather to their (Mikrotik?) router querying a certain domain in a certain interval.
If that's the case, no amount of TTL manipulation would change that.
You'd have to educate the client device that's issuing the queries in the first place.
A solution or rather workaround would be to have the router distribute Pi-hole as local DNS via DHCP while it keeps using is own upstream DNS servers. That way, you wouldn't see your router's excessive queries in Pi-hole's Query Log.
For the domain I checked (a different one) the name server reported the 7200 seconds. For the corrected domain (the one you listed), the TTL is slightly less.