Discussion:
[Dnsmasq-discuss] How to answer DNS for a host that has not gotten a lease?
John Hanks
2016-12-29 07:58:26 UTC
Permalink
Hi,

I frequently set up static dhcp-host entries for hosts that won't boot for
some time or may go away for long periods but I'd still like to have
dnsmasq respond to DNS queries based on this host/static IP. Currently I
accomplish this by having a script which parses my dhcp-host entries and
builds a host file for all the entries. Is there any way to tell dnsmasq to
do answer for hosts that may not have gotten a dhcp lease yet so that I
don't need to do this double-entry?

Thank you,

jbh
--
‘[A] talent for following the ways of yesterday, is not sufficient to
improve the world of today.’
- King Wu-Ling, ruler of the Zhao state in northern China, 307 BC
Albert ARIBAUD
2016-12-29 08:49:01 UTC
Permalink
,

Le Thu, 29 Dec 2016 07:58:26 +0000
Post by John Hanks
Hi,
I frequently set up static dhcp-host entries for hosts that won't
boot for some time or may go away for long periods but I'd still like
to have dnsmasq respond to DNS queries based on this host/static IP.
Currently I accomplish this by having a script which parses my
dhcp-host entries and builds a host file for all the entries. Is
there any way to tell dnsmasq to do answer for hosts that may not
have gotten a dhcp lease yet so that I don't need to do this
double-entry?
Er... If the DHCP protocol required a host to already have a DHCP lease
in order to get a lease from a DHCP server, not many leases would be
sent out, since a host /always/ begins its DHCP life without a lease. :)

So, I am probably misunderstanding your problem.

Can you describe your LAN setup and the detailed step-by-step example
where dnsmasq should answer and dos not?
Post by John Hanks
Thank you,
jbh
Amicalement,
--
Albert.
John Hanks
2016-12-29 09:47:12 UTC
Permalink
My description was not good, maybe an example would be better. Hypothetical
example:

1. New machine arrives, get MAC address from label on box.
2. Add "00:11:22:33:44;55,192.168.1.1,newhost,1d" to dnsmasq config.
3. restart dnsmasq
4. host newhost.my.domain results in "not found"
5. rack and power on newhost, DHCP lease established
6. host newhost returns 192.168.1.1

The problem in my environment is that at step 4 I also want to configure a
number of other tools that will complain about the host not being found and
it may be days/weeks before the system actually gets booted up. So I'd like
DNS queries to work independently of the lease being established. For
dynamic hosts this isn't possible, but where I've tied a mac to a specific
IP it is. I kludge this by converting these entries into a hostfile at
every reload of dnsmasq with a wrapper script, but would like to eliminate
that step if there is a way to have dnsmasq just return answers it knows or
should know..

Thank you,

jbh
Post by Albert ARIBAUD
,
Le Thu, 29 Dec 2016 07:58:26 +0000
Post by John Hanks
Hi,
I frequently set up static dhcp-host entries for hosts that won't
boot for some time or may go away for long periods but I'd still like
to have dnsmasq respond to DNS queries based on this host/static IP.
Currently I accomplish this by having a script which parses my
dhcp-host entries and builds a host file for all the entries. Is
there any way to tell dnsmasq to do answer for hosts that may not
have gotten a dhcp lease yet so that I don't need to do this
double-entry?
Er... If the DHCP protocol required a host to already have a DHCP lease
in order to get a lease from a DHCP server, not many leases would be
sent out, since a host /always/ begins its DHCP life without a lease. :)
So, I am probably misunderstanding your problem.
Can you describe your LAN setup and the detailed step-by-step example
where dnsmasq should answer and dos not?
Post by John Hanks
Thank you,
jbh
Amicalement,
--
Albert.
_______________________________________________
Dnsmasq-discuss mailing list
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
--
‘[A] talent for following the ways of yesterday, is not sufficient to
improve the world of today.’
- King Wu-Ling, ruler of the Zhao state in northern China, 307 BC
Albert ARIBAUD
2016-12-29 10:06:03 UTC
Permalink
Hi again John,

Le Thu, 29 Dec 2016 09:47:12 +0000
Post by John Hanks
My description was not good, maybe an example would be better.
1. New machine arrives, get MAC address from label on box.
2. Add "00:11:22:33:44;55,192.168.1.1,newhost,1d" to dnsmasq config.
3. restart dnsmasq
4. host newhost.my.domain results in "not found"
5. rack and power on newhost, DHCP lease established
6. host newhost returns 192.168.1.1
(I'll assume that you do not actually perform step 2 in the dnsmasq
config file but in the file specified by dhcp-hostsfile option, but
that's partly beside the point)
Post by John Hanks
The problem in my environment is that at step 4 I also want to
configure a number of other tools that will complain about the host
not being found and it may be days/weeks before the system actually
gets booted up. So I'd like DNS queries to work independently of the
lease being established. For dynamic hosts this isn't possible, but
where I've tied a mac to a specific IP it is. I kludge this by
converting these entries into a hostfile at every reload of dnsmasq
with a wrapper script, but would like to eliminate that step if there
is a way to have dnsmasq just return answers it knows or should know..
The behavior you describe is perfectly normal dnsmasq behavior. Step 2
defines a static *DHCP* lease, but not a *static* *DNS* entry-- see
options dhcp-hostsfile and dhcp-host in the man page.

What you want is provided by option host-record, and manage two files:
the static lease file (the one in step 2) to map the MAC and IP via DHCP
and possibly assign the DHCP client a hostname, and a hosts file to
map the IP and name statically in the DNS.

(and no, I don't know of a way to combine dhcp-host and host-record
into a single line, and I don't think there is except maybe through
scripting)
Post by John Hanks
Thank you,
NP/HTH
Post by John Hanks
jbh
Amicalement,
--
Albert.
John Hanks
2016-12-29 10:35:37 UTC
Permalink
Post by Albert ARIBAUD
the static lease file (the one in step 2) to map the MAC and IP via DHCP
and possibly assign the DHCP client a hostname, and a hosts file to
map the IP and name statically in the DNS.
(and no, I don't know of a way to combine dhcp-host and host-record
into a single line, and I don't think there is except maybe through
scripting)
This is effectively what I do now, with a reload script that automates
maintenance of the hosts entries. I was just hoping to avoid maintaining
two configurations for each host, even if one is easy enough to generate
from the other.

Thanks,

jbh

Continue reading on narkive:
Loading...