<div dir="ltr">Thanks! That makes sense. I will give that a shot.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 21, 2020 at 3:06 AM Geert Stappers <<a href="mailto:stappers@stappers.nl" target="_blank">stappers@stappers.nl</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, Apr 20, 2020 at 10:27:11PM -0400, Jiawen Chen wrote:<br>
> Hi,<br>
> <br>
...<br>
> <br>
> I'm using dnsmasq for DHCP + DNS on my home LAN and use dhcp-host to<br>
> statically assign an IP address and hostname. However, I'm discovering that<br>
> while it works most of the time, sometimes, ssh for example, can't find the<br>
> host by name, only IP. One instance is a Linux VM. Initially I can ssh into<br>
> the VM. But if I power down the VM for say a few days, and start it back<br>
> up, the name is missing (even though it is somehow assigned the same IP (it<br>
> keeps its MAC)).<br>
> <br>
> dnsmasq.conf:<br>
> ```<br>
> # other irrelevant stuff<br>
> <br>
> no-resolv<br>
> server=8.8.8.8<br>
> server=8.8.4.4<br>
> server=1.1.1.1<br>
> <br>
> expand-hosts<br>
> domain-needed<br>
> bogus-priv<br>
> local=/internal/<br>
> <br>
> # Assign 192.168.0.150 to my living room pc<br>
> dhcp-host=<livingroom_pc_MAC_redacted>,192.168.0.150,livingroom.internal,infinite<br>
> <br>
> # Assign 192.168.0.151 to my file server<br>
> dhcp-host=<fileserver_MAC_redacted>,192.168.0.151,fileserver.internal,infinite<br>
> ```<br>
<br>
I suggest to change the ',infinite' into something like ',12h' for<br>
the servers that are be powered-off of for several days.<br>
<br>
What I think is that the DNS cache entry expires ( and I think that it<br>
is valid behaviour.)<br>
<br>
Expriment that can be done:<br>
<br>
* Restart dnsmasq, so it forgets about dhcp-hosts in DNS cache<br>
* Check cache dump with SIGUSR1<br>
* Power-on an infinite DHCP client e.g. the Linux VM<br>
* Check cache dump with SIGUSR1<br>
* Regular work with the example Linux VM<br>
* Power-off the infinite DHCP client<br>
* Sample several days the cache dump<br>
* Report when the DNS entry of the powered-off server is gone<br>
<br>
<br>
Recipe to sabotage the expriment:<br>
while true<br>
do<br>
nslookup linuxVM > output<br>
process_output<br>
if hostname_not_found<br>
then<br>
exit<br>
fi<br>
sleep 2 hour<br>
done<br>
<br>
because it keeps the DNS entry in cache.<br>
<br>
<br>
> <br>
> For these static DHCP leases, is the best practice to set them in<br>
> /etc/hosts instead?<br>
> <br>
> I also discovered --host-record, which does something very similar. Is<br>
> there an advantage in using one option vs the other?<br>
> <br>
<br>
<br>
Groeten<br>
Geert Stappers<br>
-- <br>
Silence is hard to parse<br>
<br>
_______________________________________________<br>
Dnsmasq-discuss mailing list<br>
<a href="mailto:Dnsmasq-discuss@lists.thekelleys.org.uk" target="_blank">Dnsmasq-discuss@lists.thekelleys.org.uk</a><br>
<a href="http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss" rel="noreferrer" target="_blank">http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss</a><br>
</blockquote></div>