Is it possible to resolve a MAC address to an IP address?

I have some dynamic IP's (and Id rather not change that!).
But nonetheless I'd like to send http requests to the device.

Also while I'm at it , I don't suppose it's possible to set a timeout on the httpGet / asyncHttpGet .. the current setting is about 30 seconds, I'd like shorter

So, the answer is likely to be "its difficult" .. web searches suggest using ARP, which really isn't going to fly in the groovy world of Hubitat.

Why not reserve addresses for those devices in your router (or modem/router combo) to always have the router assign the same IP address to those devices. You don't need to cancel dynamic IP addresses for other devices that don't need to go to a static IP address for every device. Reserving the IP address just means that the particular device will always be assigned the same IP address. I use it for the Hubitat hub, my main computers, my printer, and my Iris V1 cameras as I need them to have an address that is stable while allowing the random addressing for other devices such as laptops that don't need such stability.

2 Likes

ARP cache.

Or DNS names? Why use IPs at all?

How would one use DNS names in a home where devices don't have names to resolve?

1 Like

In my Asus router, when I use the DHCP Reservation feature I also assign a name. I can then use that name to access that machin on my home network. My DNS server for all of my systems is set to my Asus Router. If it can resolve the name locally, it does. Otherwise it send the DNS request to my ISP's DNS server.

Yes, but most people don't do that, nor would most want to even if their router supported it.

Obviously that is an answer to the "how", but not an answer to the "why bother" above. :smile:

If you are using LAN calls from the device to Hubitat, the IP and MAC address of the device making the call to the hub is passed to the parse() function. If you can have your device make a periodic "check-in" call to the hub, that will keep the addresses up to date and ensure that it's always reachable.

You can't resolve a MAC address to a IP -- the MAC address only contains the Manufacturers ID and Product.

But.... you can use nmap too find which IP a MAC address it's using.

nmap -sP 192.168.0.1/24

That scans the entire 192.168.0.1 - 192.168.0.255

Example

# nmap -Pn 192.168.0.31

Starting Nmap 7.40 ( https://nmap.org ) at 2019-04-11 12:32 PDT
Stats: 0:00:00 elapsed; 0 hosts completed (0 up), 1 undergoing ARP Ping Scan
ARP Ping Scan Timing: About 100.00% done; ETC: 12:32 (0:00:00 remaining)
Nmap scan report for 192.168.0.31
Host is up (0.00070s latency).
Not shown: 997 closed ports
PORT     STATE SERVICE
80/tcp   open  http
443/tcp  open  https
8080/tcp open  http-proxy
MAC Address: 00:17:88:29:80:3F (Philips Lighting BV)
2 Likes

Sure you can. That's the whole purpose of ARP. That's what Nmap's using under the hood.

Yes I know but if it was that obvious the OP wouldn't be here asking this question.

So I gave a layman's explanation which is still correct.

And if you know the MAC address you can also do this to determine the device that's using it.

nmap -sP 192.168.0.1/24 |grep 00:17:88:29:80:3F

MAC Address: 00:17:88:29:80:3F (Philips Lighting BV)

There are a few ways to figure out the device that's using the MAC address.

I'll show my age here and confess that I used to administer a network of diskless Sun workstations. I used RARP (Reverse Address Resolution Protocol) to enable a system that was booting up to find its IP address based on the only thing it knew for sure at boot time: its MAC address.

The tools for doing this are still around, and part of many Linux distributions. There's a daemon that supports RARP, called rarpd. See: Ubuntu Manpage: rarpd - Reverse Address Resolution Protocol (RARP) daemon

So here's another way to determine a hosts IP address from its MAC address. I don't think this helps the OP, as rarpd requires a static database of MAC to IP mappings. Just historic musing...

Carry on.

1 Like

There is 1 more way to resolve a MAC address. In linux there is a cli called arp-scan that will help you also.

sudo arp-scan -g 192.168.0.0/16

Example:

sudo arp-scan -g 192.168.0.0/16 |grep b8:27:eb:bb:1a:44

192.168.0.4 b8:27:eb:bb:1a:44 Raspberry Pi Foundation

1 Like

Not "exactly" what is desired, but if you only have a single HE on your LAN, and "Bonjour" is in use on your network, then the HE responds to "hubitat.local". In other words, you can access the HE by name without knowing that (possibly changing) IP address.

That said, this is really not a good thing for the HE to do. It SHOULD use the name you have given your HE. So if you called it 'myhub' the Bonjour name should be myhub.local. I don't know what happens if you have more than one HE on the same LAN.

I really should have said 'mDNS', not Bonjour. Bonjour is Apple's implementation, I think.