I have a number of devices which are not up all the time, and frequently their leases expire. They are entered as reservations with a fixed IP address and name associated with the MAC address. They end up like this in /etc/config/dhcp
config host
option name 'GuestBedroomMini'
option dns '1'
option mac '38:8B:59:84:D9:04'
option ip '192.168.132.14'
When the lease is outstanding the DNS name is defined and resolves, but it does not when the lease is not outstanding. It appears necessary to enter either a "config domain" entry in that file, or an entry in /etc/hosts. Which is somewhat duplicative.
I've tried reviewing all the dhcp/dnsmasq options and have not seen one that says, essentially, resolve name even if lease not outstanding.
Is it indeed necessary to define in two places to have both DHCP work, and DNS work with inactive static reservation?
discovery hasn't been powered on since the last reboot of my router, accordingly there is no active dynamic lease, just the preconfigured static lease:
Make sure that you configure the correct domain and that your clients actually accept this search domain, as part of their DHCP lease (e.g. systemd-networkd does not, unless explicitly configured to UseDomains=yes). Otherwise you'd have to use the fully qualified domain name instead, e.g. guestbedroommini.lan..
I tested it from a cold start with no leases and it did not work for me (and I have that setting which is the default). I did see it continue to resolve after a lease was deleted manually. I think maybe it's being cached.
It's not a domain/naming issue, the name resolves immediately with the same nslookup if I turn the device on and it pulls an IP.
This is a well-known behavior for the dhcp-host option which requires to duplicate host names with the host-record option to resolve names for inactive leases.
However, OpenWrt Dnsmasq init script should allow to resolve FQDN anyway:
Thanks, @vgaetera , if I understand you, you are saying it really should work anyway. Let me set up another clean test and try it. I found that code, and mine differs a lot at the top, I think that's recent additions. The code referenced is present and that gives me a good idea how it should function. More to follow when I get some time to experiment.
I did a fresh reboot, and it does come up with all the names resolving. In other words I can't reproduce it at the moment. Restarting the service (which is how I was testing) and restarting the router now both yield resolution.
But I am certain I had a situation where an inactive leased item would not resolve. I just don't know how it came to be in that situation.
I'll post more if I figure that out, but thank you and for now it appears to work just fine.
I'm not having an issue with domain suffixes, I'm aware of how all that works. My problem was lack of resolution, period. But I can't reproduce it now. I'm trying though.