Sorry, I should have been more specific
You want your router to be telling all the devices on your network to ask your Home Assistant computer for DNS information. Usually you set this in the same config page on your router as things like the router’s own IP address, Subnet Mask, Search Domains and so on.
Most routers will either have a field for “Primary DNS” and “Secondary DNS”, or there will be a multi line text field for DNS that lets you set multiple servers either comma separated or one per line.
You want Home Assistant’s IP as the first (or primary) one, and your ISP’s DNS server’s IP address as the second. That way if your Home Assistant is down for any reason, yours devices can still get to the internet.
This seems odd to me. Do you mean there is only one DNS server from your ISP, but only one (so no secondaries)?
So you don’t want to put Home Assistant’s IP address in defaults, you want your ISP’s DNS server/s. Defaults is where DNSmasq goes looking if there isn’t a item in the host section for the domain it has been asked for. If it’s own IP is there, then it will ask itself in a loop for the answer, realise it doesn’t have the answer, go to its defaults list and ask the first IP in there for the answer. Which would be itself. And around and around it goes. There is probably logic in the program to stop it endlessly looping in this situation, but you can see why you wouldn’t want Home Assistant’s IP there.
So just your ISP’s DNS IP in the defaults section for now.
The bit you have in your hosts section above is fine, as long as that is your Home Assistant’s IP
You aren’t alone here. I’ve been using DNSmasq for years outside Home Assistant and it still finds ways to surprise me
When this all works, you still will need to use the duckdns URL to connect to Home Assistant, as your SSL certificate that secures the connection will only produce a valid connection if you start it with the domain name in the certificate.
When you are on your home network, however, when you connect to that domain name, you will be connecting directly to your Home Assistant, not going out to the internet and back again as you are without this DNS setup.
You can verify this using a DNS lookup utility. If you’re on a Mac for example, or Linux with the dns-utils package installed, you should be able to enter
nslookup xxx.duckdns.org
in a terminal, and it should return your Home Assistant IP address.
Not sure what utility to use on Windows for this, sorry!