So, say I have a host dhcphostname.lan in my network, it changes it's IP address very often, the only part that won't change is it's hostname.
I can nslookup it's hostname to get it's IP. But it doesn't work if I'm trying to lookup it's subdomain, say test1.dhcphostname.lan or test2.dhcphostname.lan.
My question is, is there an option I can flip so OpenWrt knows to resolve *.dhcphostname.lan to the same IP address as dhcphostname.lan?
Sorry, that wouldn't work as it requires to setup static resolves/records.
In my case, I need it to be done automatically, because it's not just one host needs to be configured. The host changes IP address, and the host comes and goes.
I've eventually settled down on writing a DNS proxy that transforms the query for a sub-hostname to the hostname itself before sending it back to Dnsmasq.
It goes like: Client (Sends query for xxx.host.dev.lan) -> Dnsmasq (Detects .dev.lan and forward to my proxy) -> My DNS Proxy (Sees xxx.host.dev.lan, strips xxx and dev.lan, so the domain becomes host. Then it sends host back to Dnsmasq) -> Dnsmasq (Sees host, found the result) -> My DNS Proxy (Receives the result, repack it as the result for xxx.host.dev.lan, and then reply to the previous Dnsmasq query) -> Dnsmasq (Receives the final result for xxx.host.dev.lan, reply to the client) -> Client (Receives the final result).
Yeah, I really wish Dnsmasq can add an option for this function. But now I'll just have to live without it.
I was doing almost the same thing with no sucess. I think it's because instead of calling uci to modify /etc/config/dhcp like in your script, I was directly writing a new config file with content address="/${HOSTNAME}/${IPADDR}" to /tmp/dnsmasq.d.