Dnsmasq .lan domain while still using knot resolver

After recent update, my change in /etc/init.d/kresd was overwritten.

But I found some new, better options.

In /etc/config/resolver there is section for kresd containing two commented-out lines:

option include_config '/tmp/kresd.custom.conf'
option hostname_config '/etc/hosts'

The first line allows to add custom rules to that config files. I changed it to /etc/kresd.custom.conf. This file won’t get overwritten. For example, the rules suggested above to forward local domain to dnsmasq:

policy.add(policy.suffix(policy.FORWARD('127.0.0.1@5353'), policy.todnames({'lan'})))
policy.add(policy.suffix(policy.FORWARD('127.0.0.1@5353'), policy.todnames({'10.in-addr.arpa'})))

This is for 10.0.0.0/8 network. You still need to hack /usr/lib/kdns_modules/policy.lua to allow forwarding reverse DNS of private zone…

Now, there is easier option, as Knot resolver itself now resolves most of the local domain. Missing just the router itself and the reverse queries. The first problem can be solved by uncommenting the other option. Add something like this to /etc/hosts:

10.0.0.1 turris.lan turris

After restarting (/etc/init.d/kresd restart), Knot resolves all hosts in local domain. Still, I opted for Dnsmasq for the bonus of reverse queries.

2 Likes