[IP][Mac]Address -> Device Name

I can use arp -a to get a list of all the IP and MAC addresses on my LAN
but what I cannot figure out is how to convert them (look up) the DEVICE name associated with each.

Not JUST the computer, for example on my Lan

IP : 192.168.xxx.xxx Mac : 00:11:32:XX:XX:XX is my Synology Nas with a device name of “DiskStation”

I found a freebie app called “IP Scanner” that does return this information (along with the device manufacturer even, so I know it is available

I have looked at every Unix [OSX] command line function I have been able to find to no avail…

So does anyone know how to get this data given the IP and/or Mac address?

If I remember correctly, your arp table doesn’t have to be complete. Assuming your Lan is on a Switch instead of a Hub, it shows the hosts your machine was connected with previously somehow. And I don’t think entries are automatically deleted from the table if a host goes offline or is added when a new one comes online.

Your switch has it’s own arp table (probably most complete if your Lan only has 1 switch). So has your router and your gateway.

As for hostnames, I think you can only get them via lookups.

IP Scanners basically do ping sweeps over the subnet to see if certain ports respond. If it does, then it does a lookup for the hostname.

Although a bit overkill (and not installed by default) but ‘nmap’ is an all-in-one tool for these kind of things.

Thanks Marco, but I’m not sure how that addresses the question…
I know about ARP… it returns a table of 256 entries for my LAN… and indicates which have an IP and MAC address assigned (for me that is currently 9 entries)…
I need to be able to take those 9 entries and say… This is my router (which is the ONLY one Arp names), the next is my printer, my Nas, my iPad etc…

The IPScanner app does this (but the “trial” only does a few devices, plus I want to use the data for other things as well)

PING, NSLOOKUP, ARP, SMCUTIL, DIG none return any NAME information, but it has to be there somewhere

As far as I understand, it’s a mixture of things because hostnames themselves are not part of TCP/IP.
LAN Hostnames/machine names are set with things like NetBui, NetBios, Bonjour, DNS-suffix, Search Domain etc. but unless you run a local DNS and each host has a full FQDN, there isn’t really a standard.

It may work if you set the DNS-suffix (Windows) / Search Domain (Mac) in your router’s DHCP settings. That way, the hosts register themselves with the router and it should respond to lookups.

edit: http://www.howtogeek.com/69696/how-to-access-your-machines-using-dns-names-with-dd-wrt/

Thanks Marco… but I think you are still missing the point…
I should not have to install anything new, I should not have to reprogram my router… This information is already available to other programs… But if you are not aware of the method they use to expose it, thats ok… I’ll keep looking…

Everything so far is NAME -> IP or NAME -> Mac
I need IP -> Name or Mac -> Name

On Windows I use nbtstat -a , don’t know if that’s available on OSX though.

Sigh… its not, nor are a number of other Unix/Linux flavors I’ve run across…

If I understand the question correctly you’re just trying to resolve NetBIOS names.

Can you use:

smbutil status ipaddress ?

[quote=270535:@Christian Wheel]If I understand the question correctly you’re just trying to resolve NetBIOS names.
Can you use:
smbutil status ipaddress ?[/quote]

that DID work for SOME of the IP addresses… It named the router and my NAS… but nothing else… “operation timed out”

Don’t know how scanners work but ‘nslookup’ works on some IPs…
On image, one working example and one not working…

Update: It works on 99% of the tried LAN IPs here at work.

On my LAN NSLOOKUP worked on ONE of nine IP addresses… I think it will return the name of any device that meets the criteria of a “server”… which in my case in my NAS and the router… but all the other devices are "different’… even though the IPSCANNER.APP can and does find their names

Does ping -a do anything to help?

http://www.boisseau.co.uk/charlie/programming/ICMPSocketReadMe.html
and
http://www.boisseau.co.uk/charlie/programming/ICMPSocket.zip
should help…

[quote=270552:@Jean-Yves Pochez]http://www.boisseau.co.uk/charlie/programming/ICMPSocketReadMe.html
and
http://www.boisseau.co.uk/charlie/programming/ICMPSocket.zip
should help…[/quote]

neither PING nor TRACEROUTE contain this information either, nor does IFCONFIG

Would seem you need SNMP
http://www.pbsw-code.net/code/realbasic/classes/pbsw-SNMP/index.html

Sorry. On Windows the -a flag means show the host name, on Mac it means ring the bell!!

gotta love standards eh

Norman… that code you referenced says a) it is not quite “done”, and b) is for ancient version of RealBasic (5.5), OSX does have SNMPWALK, but I have yet to figure out any meaningful information from/for it

Would be nice if @Mike Cotrone chimed in as this is sort of his area of expertise

http://www.net-snmp.org/docs/man/snmpwalk.html
has an example way down at the end

http://www.net-snmp.org/docs/man/snmpcmd.html

OS man pages are very close to these from what I can tell

problem I have with SNMPWALK is “the host”
I’ve tried every think I can think of… I assumed it would be the router IP address, but its not

use the IP address

something like
snmpwalk -v 2c -c public