I made some research and can't find a solution, I'm starting to think this is not possible.
I'm running arp -a
in my terminal and I'd like to get the hostnames of the LAN devices.
host x.x.x.x
returns:
Host x.x.x.x.in-addr.arpa. not found: 3(NXDOMAIN)
nslookup x.x.x.x
returns:
** server can't find x.x.x.x.in-addr.arpa: NXDOMAIN
Is there a way to do this?
I found a way thanks to @gordon-davisson who set me on the right path.
First I get the gateway IP with: route get default | grep gateway
Then for every LAN device I run: host LAN_IP Gateway_IP
This returns:
Using domain server:
Name: 192.168.x.x
Address: 192.168.x.x#x
Aliases:
x.x.168.192.in-addr.arpa domain name pointer LAN-host-name.
I parse the response to get the name displayed at the end.
Side note: it still doesn't display the LAN host-names with arp -a
after that.