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=8.8.8.8
> server=8.8.4.4
> server=1.1.1.1
> 
> expand-hosts
> domain-needed
> bogus-priv
> local=/internal/
> 
> # Assign 192.168.0.150 to my living room pc
> dhcp-host=<livingroom_pc_MAC_redacted>,192.168.0.150,livingroom.internal,infinite
> 
> # Assign 192.168.0.151 to my file server
> dhcp-host=<fileserver_MAC_redacted>,192.168.0.151,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
  do
     nslookup  linuxVM  >   output
     process_output
     if  hostname_not_found
     then
        exit
     fi
     sleep 2 hour
  done

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?
> 


Groeten
Geert Stappers
-- 
Silence is hard to parse

_______________________________________________
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss

Reply via email to