Question about Dnsmasq - dns cache

Hi all !
I have luci-app-https-dns-proxy installed, it includes 2 different dns domains, which can give out different IP addresses, and if you turn on dns cache to 1000 in Dnsmasq, then after a while, for example, some will not open in the browser sites until you disable dns cache. At the moment it is disabled, but I would like to enable it, but I don’t know how to solve this problem. Does anyone have any thoughts on this matter ?
As an opportunity to leave only one DNS domain at luci-app-https-dns-proxy, but the second as a spare, plus paired, they work very well

This doesn't sound to me like it's anything to do with the https proxy, tt sort of sounds like the time-to-live in dnsmasq's cache is too high and some of the host IPs are changing before they get refreshed. Maybe add this to /etc/dnsmasq.conf and restart dnsmasq to see if it helps?

max-cache-ttl=120

From the man page:

--max-cache-ttl=<time>
    Set a maximum TTL value for entries in the cache. 

See also the max-ttl entry, just above max-cache-ttl, that might be something to consider, too.
https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

1 Like

Maybe you're right. Tell me how to change it via PuTTY max_cache_ttl ?
I'm not good at this
For example, set it to 1 hour
right or wrong ?

vi /etc/config/dnsmasq
option max_cache_ttl '3600'
/etc/init.d/dnsmasq restart

or should this be done?

vi /etc/dnsmasq.conf
max_cache_ttl=3600
/etc/init.d/dnsmasq restart

please tell me someone

I think I found how

uci set dhcp.@dnsmasq[0].cachettl='3600'
uci commit

check the states with this command
uci show dhcp.@dnsmasq[0].cachettl

the value 3600 is one hour of time in seconds

Yup, you're on the right track, but I think that should be max_cache_ttl (see bottom of list at https://openwrt.org/docs/guide-user/base-system/dhcp#all_options):

$ uci set dhcp.@dnsmasq[0].max_cache_ttl=120
$ uci commit
$ /etc/init.d/dnsmasq restart

$ grep cache /tmp/etc/dnsmasq.conf.cfg01411c
cache-size=1000
max-cache-ttl=120
1 Like

Thank you for the right direction !
I just didn’t have odhcpd installed, I installed it and the problem went away and the max-cache-ttl settings were left at 3600.

At the same time, I learned how to use the vi editor, I’ve been wanting to for a long time, but I never got around to it :slight_smile:

1 Like

I want to thank you. The problem was that I built an assembly without ipv6, installed the odhcpd package separately and now the DNS cache works fine. But I need it, because when using nextdns the number of requests per week exceeded 300 thousand and filtering was turned off, but now it’s normal, it lasts for a month.

1 Like