On Mon, Apr 20, 2020 at 10:27:11PM -0400, Jiawen Chen wrote:
> Hi,
> I'm using dnsmasq for DHCP + DNS on my home LAN and use dhcp-host to
> statically assign an IP address and hostname. However, I'm discovering that
> while it works most of the time, sometimes, ssh for example, can't find the
> host by name, only IP. One instance is a Linux VM. Initially I can ssh into
> the VM. But if I power down the VM for say a few days, and start it back
> up, the name is missing (even though it is somehow assigned the same IP (it
> keeps its MAC)).
> dnsmasq.conf:
> ```
> # other irrelevant stuff
> no-resolv
> server=
> server=
> server=
> expand-hosts
> domain-needed
> bogus-priv
> local=/internal/
> # Assign to my living room pc
> dhcp-host=<livingroom_pc_MAC_redacted>,,livingroom.internal,infinite
> # Assign to my file server
> dhcp-host=<fileserver_MAC_redacted>,,fileserver.internal,infinite
> ```

I suggest to change  the   ',infinite'   into something like  ',12h' for
the servers that are be powered-off of for several days.

What I think is that the DNS cache  entry expires ( and I think that it
is valid behaviour.)

Expriment that can be done:

 * Restart dnsmasq,  so it forgets about dhcp-hosts in DNS cache
 * Check cache dump with  SIGUSR1
 * Power-on an infinite DHCP client e.g. the Linux VM
 * Check cache dump with SIGUSR1
 * Regular work with the example Linux VM
 * Power-off the infinite DHCP client
 * Sample several days the cache dump
 * Report when the DNS entry of the powered-off server is gone

Recipe to sabotage the expriment:
  while true
     nslookup  linuxVM  >   output
     if  hostname_not_found
     sleep 2 hour

because it keeps the DNS entry in cache.

> For these static DHCP leases, is the best practice to set them in
> /etc/hosts instead?
> I also discovered --host-record, which does something very similar. Is
> there an advantage in using one option vs the other?

Geert Stappers
Silence is hard to parse

Dnsmasq-discuss mailing list

Reply via email to