Discussion:
[Dnsmasq-discuss] Have DNSMasq only assign addresses if there is a corresponding entry in /etc/hosts?
James Lacy
2017-07-18 14:00:11 UTC
Permalink
Is there a way to have DNSMasq assign an address only if a client has a
hostname that corresponds to an entry in /etc/hosts?

Normally I'd do this by MAC address, but this is for a VM range and the MAC
addresses will change each time they are cloned out from the template, and
for other reasons I don't want to set static MAC addresses in the VMs.
--
--James
--***@gmail.com
Maurice Walker
2017-07-18 17:47:33 UTC
Permalink
Post by James Lacy
Is there a way to have DNSMasq assign an address only if a client has a
hostname that corresponds to an entry in /etc/hosts?
Disable dynamic allocation and specify the hostnames which are allowed to be
allocated an IP address:

--dhcp-range=<start-addr>,static
--dhcp-host=<hostname1>
--dhcp-host=<hostname2>

You could also list the hostnames in a file (or let a script do that) and let
dnsmasq read it:
--dhcp-hostsfile=<path>

Either way the associated IP addresses will be read from /etc/hosts.
James Lacy
2017-07-18 20:04:18 UTC
Permalink
Can this be defined in the configuration file instead of arguments?

My configuration consists of the below but I can't get any offers to the
discover requests from the client

dhcp-range=192.168.0.0,static
dhcp-hostsfile=/etc/dnsmasq.hosts

The file consists of the following format:
192.168.0.1,linuxvm1

/etc/hosts has something similar:
192.168.0.1 linuxvm1.lab

The linux VM has a hostname of linuxvm1
Post by Maurice Walker
Post by James Lacy
Is there a way to have DNSMasq assign an address only if a client has a
hostname that corresponds to an entry in /etc/hosts?
Disable dynamic allocation and specify the hostnames which are allowed to be
--dhcp-range=<start-addr>,static
--dhcp-host=<hostname1>
--dhcp-host=<hostname2>
You could also list the hostnames in a file (or let a script do that) and let
--dhcp-hostsfile=<path>
Either way the associated IP addresses will be read from /etc/hosts.
--
--James
--***@gmail.com
Loading...