[SOLVED] How do I increase DNS local-ttl in OpenWRT?

I need to increase TTL on the local DNS resolution from 0 to 10 seconds. The reason I need it is because when I enable sending logs to an external syslog server, the external syslog server floods OpenWRT's dnsmasq with dozens of DNS requests per second for every host name that it receives in syslog messages. There is no reason to resolve the same host name over and over and over again every time it's mentioned in the syslog message received by the syslog server. So, I want to increase the local DNS TTL and see if I can dramatically reduce the number of DNS requests from the Syslog server as well as the size of the syslog files saved on the Syslog server because every DNS request is also logged into the same file.

I tried to add the following line to the config section of /etc/config/dhcp
option localttl '10'

Then, I restarted dnsmasq like this:

service dnsmasq restart

However, TTL continues to be 0 on DNS requests to OpenWRT for hostnames defined locally in OpenWRT. This dig was done on a Mac requesting the A record of the QNAP server on my LAN after I made the aforementioned change and restarted the dnsmasq service.

 % dig +nocmd +noall +answer +ttlid a qnap.mydomain.local
qnap.mydomain.local.	0	IN	A	192.168.200.30

Thank you!

1 Like

I've now tried:

option local-ttl '10'
/etc/init.d/dnsmasq restart

This setting doesn't take, as dnsmasq still resolve local A-Records with the TTL of 0. Anyone has any ideas?

Thanks!

Thank you.

It's best to change your domain to .lan or .home and avoid using domain .local for DNS.
The domain .local is reserved for mDNS which may conflict with DNS on the clients.

2 Likes

My domain is not .local. I obfuscated the domain name in my post.

It's actually a true domain with the TLD of .com

1 Like

Thank you once again, @vgaetera ! Changing the option in /etc/config/dhcp under the section config dnsmasq to this:

local_ttl '10'

and the reloading dnsmasq like this:

/etc/init.d/dnsmasq reload

changed the TTL from 0 to 10 seconds. Since then, I changed TTL again from 10 seconds to 15 seconds:

dig +nocmd +noall +answer +ttlid a qnap.mydomain.local
qnap.mydomain.local.	15	IN	A	192.168.200.30

My QNAP Syslog server is now very happy and so am I. The amount of information being logged is probably about 15% of what was logged before. Hence, the resource utilization as well as the storage space consumed by syslog is now a fraction of what it was before when TTL on dnsmasq DNS responses was set to 0.

4 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.