DD-WRT: DNSMasq expand-hosts not working
This question is old, but it's one of the top google results for the issue, and I finally figured it out.
The problem is that's not what expand-hosts
does. The documentation on it is very fuzzy, but what expand-hosts
does is adds the domain to host entries in /etc/hosts
, not to dns queries. So for example
/etc/hosts:
10.77.0.5 astatichostname
dnsmasq.conf:
expand-hosts
domain=example.com
Then dns queries for astatichostname.example.com
will resolve to 10.77.0.5
(in addition to DNS queries for just astatichostname
).
Solution:
So, the solution is to get dd-wrt to create the entries in /etc/hosts
without the domain on them, and then tell dnsmasq to consider those host entries as part of the example.com
domain when a fully qualified A record DNS query comes in.
To do this you have to:
- Put the
example.com
domain in the Domain Name field on the Setup -> Basic Setup page under Optional Settings. - Blank the LAN Domain setting on the Services page under DHCP Server.
- Add
expand-hosts
to Additional DNSMasq Options on the Services page under DNSMasq
Step #1 controls the domain=
setting that gets put in the dnsmasq.conf
file. Step #2 removes the domain from the entries that get put in /etc/hosts
. Step #3 tacks the domain onto the entries in /etc/hosts
when a fully qualified DNS query comes in.
I'm so glad dd-wrt made this nice and simple...
The following works for me on my DD-WRT:
expand-hosts
local=/lan/
domain=lan
I think it's because you're missing the local
setting. I also have lan
set as my "LAN Domain" in the GUI.