Hostname: fields, IP vs hostnames

Is anyone using hostnames in the various host: fields for configurations? Do they pretty much universally work or is it more dependent on the integration?

I have my own DNS name, so my household items make use of it. It would be more convenient to use rokubedroom.myhostname.net instead of the IP for the device in the configuration as an example.

I just simply use the short hostname, eg

host: bedroom

My local DNS does the rest. It really depends if you have your DNS setup correctly.

Can you advise how you have your DNS setup to be able to get this to work. Currently I’ve been using the IP and a static DHCP list in my setup. But so it’s more dynamic, I’m looking to move over to using the hostnames instead of IPs.

I use dnsmasq. dnsmasq works as a dhcp server and a DNS server.

I started with it on a Pi 1 and it worked well. If you define a fixed IP in the config file it will always give that IP address out to the specified MAC address. It will also return the IP address when the defined hostname is searched via DNS.

I have since moved to pi-hole. It also uses dnsmasq, and has a nice GUI for defining fixed addresses, and seeing what addresses have been handed out.

To do either of these (which basically are the same solution) you should turn off your DHCP server on your ISP supplied router. Let dnsmasq do it all.

Let me know any questions.

Thanks for clarifying.

I have dnsmasq on my OpenWRT router. So it looks like I can do exactly as you’ve setup with Pi-Home.

It looks like local DNS name resolution is happening automatically for some hosts on my network that haven’t had a static lease set (ie. OpenWRT will show the hostname.lan). And when I ping hostname.lan I’ll get a response from that host. Is this normal behaviour? And can HomeAssistant integrations handle those hostname.lan rather than an IP in each config?

Yes, that is normal.

yes

Well, maybe it is because I run this is docker, maybe not… but this doesn’t work for me.

I’ve tried:

host: rokubedroom
and
host: rokubedroom.mysecretdnsname.com

Both get a
"The following components and platforms could not be set up:

  • roku
    Please check your config."

I can ping either of those just fine on my LAN.

Going back to an IP works perfectly.

Using the hostnames on a couple of configs worked for a couple of days but now I’m getting an error that the hostname can’t be resolved.

Couldn't connect to host firetv-livingroom.lan:5555, error: Name does not resolve

However when I ping or nmap the hostname on the 5555 port I get a valid response. Whats going wrong?