Hi all,
I'm having a hard time getting dnsmasq to answer DNS queries for local hostnames, whether I configure them in /etc/hosts or using static DHCP leases. I'm running OpenWRT 15.05 with dnsmasq 2.73 on a Turris Omnia router.
What I want is simple: when $host gets an IP address $a from the DHCP server, DNS queries for $host should return $a. If I have to configure static DHCP leases for this to work, that's fine -- I like knowing what my IP address is going to be anyways. From the OpenWRT docs, it sounds like this is exactly what dnsmasq is designed for, and OpenWRT configures it to do that by default. So I'm confused as to why it's not working for me.
First, here is my /etc/config/dhcp file (generated by luci):
root@turris:/etc# cat /etc/config/dhcp
config dnsmasq
option domainneeded '1'
option boguspriv '1'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
option domain 'lan'
option expandhosts '1'
option authoritative '1'
option readethers '1'
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.auto'
option localservice '1'
option port '0'
option logqueries '1'
option nonwildcard '0'
option local '/lan/'
config dhcp 'lan'
option interface 'lan'
option limit '150'
option leasetime '12h'
option dhcpv6 'server'
option ra 'server'
option ignore '0'
option start '2'
list dhcp_option '6,192.168.45.1'
config dhcp 'wan'
option interface 'wan'
option ignore '1'
config odhcpd 'odhcpd'
option maindhcp '0'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'
config host
option name 'namazu0'
option mac '00:21:86:a2:97:1a'
option ip '192.168.45.3'
config host
option name 'namazu1'
option mac '00:21:6b:ac:e3:d6'
option ip '192.168.45.4'
(namazu is a single laptop: namazu0 is its wired interface, namazu1 wireless.)
And the resulting dnsmasq.conf:
root@turris:/etc# cat /var/etc/dnsmasq.conf
# auto-generated config file from /etc/config/dhcp
conf-file=/etc/dnsmasq.conf
dhcp-authoritative
domain-needed
log-queries
localise-queries
read-ethers
bogus-priv
expand-hosts
local-service
port=0
domain=lan
server=/lan/
dhcp-leasefile=/tmp/dhcp.leases
resolv-file=/tmp/resolv.conf.auto
addn-hosts=/tmp/hosts
conf-dir=/tmp/dnsmasq.d
stop-dns-rebind
rebind-localhost-ok
dhcp-broadcast=tag:needs-broadcast
dhcp-host=00:21:86:a2:97:1a,192.168.45.3,namazu0
dhcp-host=00:21:6b:ac:e3:d6,192.168.45.4,namazu1
dhcp-range=lan,192.168.45.2,192.168.45.151,255.255.255.0,12h
dhcp-option=lan,6,192.168.45.1
no-dhcp-interface=eth1
IIUC, that "server=/lan/" entry in dnsmasq.conf is the important one that is supposed to make things work. But it doesn't.
First, I've defined a bogus hostname in /etc/hosts to see if I can get back its bogus IP address:
root@turris:/etc# cat /etc/hosts
127.0.0.1 localhost
5.6.7.8 flarp.lan flarp
No luck:
root@turris:/etc# dig +short flarp.lan @127.0.0.1
root@turris:/etc# dig +short flarp @127.0.0.1
(No output to either query.)
And now one of the hostnames defined by a static lease:
root@turris:/etc# dig +short namazu0 @127.0.0.1
root@turris:/etc# dig +short namazu0.lan @127.0.0.1
I'm stumped. I must be missing something simple and obvious, but I've been through the OpenWRT docs and the dnsmasq man page and I can't see it. Help!
Thanks,
Greg