Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name resolution fails if reverse DNS zone not setup #8

Open
zxdavb opened this issue Oct 8, 2018 · 4 comments · May be fixed by #45
Open

Name resolution fails if reverse DNS zone not setup #8

zxdavb opened this issue Oct 8, 2018 · 4 comments · May be fixed by #45
Labels
enhancement New feature or request

Comments

@zxdavb
Copy link

zxdavb commented Oct 8, 2018

If the nslookup fails, then maybe a warning in the log file would be a good idea?

I was getting (note host_name is a zero-length string, ""):

Mon Oct  8 17:51:20 2018 user.debug /usr/bin/hassd.sh: post {"mac":"6c:5a:b5:4e:75:c6","host_name":"","consider_home":"24:00","source_type":"router"}

instead of:

Mon Oct  8 17:51:20 2018 user.debug /usr/bin/hassd.sh: post {"mac":"6c:5a:b5:4e:75:c6","host_name":"db-desktop","consider_home":"24:00","source_type":"router"}

This happens when reverse name lookups fails in function get_host_name in functions.sh:

root@sr-router:~# nslookup 172.27.0.99
Server:         8.8.8.8
Address:        8.8.8.8#53

** server can't find 99.0.27.172.in-addr.arpa: NXDOMAIN

Say: logger -t $0 -p warning "Reverse DNS is not setup, so names cannot be resolved"

@mueslo mueslo added the enhancement New feature or request label Oct 11, 2018
@zxdavb
Copy link
Author

zxdavb commented Oct 13, 2018

Having thought about this, I would expect this code not to:

   post $(build_payload "$mac" "$(get_host_name $mac)" "$timeout")

if $(get_host_name $mac) is a NULL string.

The reasoning is that:
a) you could have a lot of devices on your WiFi LAN, and it will be painful to keep HA's known_devices.yaml up to date (e.g. someone visits and uses your WiFi)
b) to choose which devices end up in HA, just make sure it has a lease and a reverse DNS entry (the last line, below):

uci add dhcp host
uci set dhcp.@host[-1].name=my-smartphone
uci set dhcp.@host[-1].mac='08:18:13:25:c1:87'
uci set dhcp.@host[-1].ip=192.168.0.100
uci set dhcp.@host[-1].dns=1

@ttimasdf
Copy link

Is nslookup by default using router's resolv.conf defined DNS server? If you point it to router itselves dnsmasq, the DNS lookup will have no problem.

@ttimasdf ttimasdf linked a pull request Dec 30, 2019 that will close this issue
@mueslo
Copy link
Owner

mueslo commented Feb 17, 2020

@zxdavb are you running regular dnsmasq? If so, the empty hostname is not because of not having set up the reverse DNS zone, but rather because the association event precedes assigning of a DNS name. Any subsequent events will likely have the correct DNS name, e.g. polling or disassociation events. Can you confirm that?

If so, this issue is essentially resolved by home-assistant/core#31886

@zxdavb
Copy link
Author

zxdavb commented Feb 18, 2020

I am sorry, I have too much going on to help with this at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants