dnsmasq without altering /etc/hosts file manually
I've trying to get dnsmasq working as a combined dns and dhcp server. It's infuriating so far... In short, the DNS works fine for anything added to /etc/hosts, and the dhcp works fine, but the dhcp is not updating the dns with hostname information from clients.
The outcome of this is that i can only ping a node by hostname if i know it's address, which means setting a static dhcp allocation and putting the hostname into /etc/hosts manually, which is very annoying and kind of defeats the poit of dhcp. There must be a way to get dnsmasq to update the hosts file, surely
The clients aren't using fqdn's if that matters, and i think i've tried every combinination of "expand-hosts" and "domain="
following is the dnsmasq config file contents:
domain-needed bogus-priv except-interface=tun0 dhcp-range=192.168.1.10,192.168.1.80,255.255.255.0,12h dhcp-leasefile=/var/lib/misc/dnsmasq.leases dhcp-authoritative log-queries log-dhcp
Try setting a domain with domain example.org
.
dnsmasq also has a hook to call a script dhcp-script=foo.sh
. The arguments sent to the script are "add" or "del", then the MAC address, the IP address and finally the hostname.
It should be relatively easy to quickly create a script that updates the hosts file.
The DHCP client needs to send a name to have the name made available in the DNS. Otherwise dnsmasq can supply the name, but you have to configure that in /etc/dnsmasq.conf or /etc/hosts first.
Since dnsmasq is a DNS server, you need to have a domain name. The domain-needed
part enforces that. Set a domain name in your configuration also.
So here's basically what I have:
bogus-priv
dhcp-authoritative
dhcp-host=00:0c:29:1b:62:c6,host1,192.168.1.86,infinite
dhcp-host=00:0c:29:f7:e6:7d,host2,192.168.1.89,infinite
dhcp-host=00:1e:58:94:d2:5b,192.168.1.10,infinite
dhcp-option=19,0 # option ip-forwarding off
dhcp-option=27,1
dhcp-option=42,0.0.0.0
dhcp-option=44,192.168.1.10 # set netbios-over-TCP/IP nameserver(s) aka WINS server(s)
dhcp-option=45,0.0.0.0 # netbios datagram distribution server
dhcp-option=46,8 # netbios node type
dhcp-option=6,0.0.0.0
dhcp-option-force=210,/
dhcp-option-force=211,30i
dhcp-option=option:domain-search,example.com
dhcp-option=option:router,192.168.1.1
dhcp-range=192.168.1.50,192.168.1.150,255.255.255.0,30d
domain=example.com
domain-needed
enable-tftp
expand-hosts
interface=eth0
local=/dartworks.biz/
local=/localnet/
no-poll
no-resolv
server=<ISP DNS 1>
server=<ISP DNS 2>