Why not mac address based device identification?


I’m quite new to this whole scene and based on many factors decided to go with OpenHAB with all of my home automation build.

Home Assistant seems to allow NMAP for device tracking and once connected to a device seems to store it’s physical MAC address: https://www.home-assistant.io/components/device_tracker/ which seems to make so much sense.

Why does OpenHAB not do this and especially not in Network binding?

I see that most bindings that work over the internet, identify things by IP addresses and IP addresses alone, can’t find mac addresses stored anywhere.

The mac aadress could be stored regardless, and if nmap is present and installed it would make sense to scan the network and check all found mac addresses against the devices listed as network things.

This would make the whole thing so much more dynamic by being able to just plug new devices and not having to give them static IP addresses, as IP addresses can change quite often, but in most cases mac addresses don’t change unless forcefully changed by user.

I understand that this could go very deep and be too much of a rewrite of the whole platform, but it would also allow for a much more modular system.

Best regards,



You are free to create such a binding :wink:

And you don’t have to create a static IP on the device, just make the DHCP lease static on your dhcp server/router.
But I do understand the request.

I know I can make the lease static on the router, but it doesn’t change the fact that another something needs to be configured.

I don’t think it’d make sense to create an identical binding to what already exists as the Network binding. However it does seem that adding this functionality to the Network binding would by quite an extensive rewrite and I don’t suppose a pull-request like that would go through any time soon. *(Identical in the sense that they have the same purpose)

But this thing goes way deeper, as all the bindings for things that connect over LAN seem to be following the same practice of just going by IP address(/hostname) and not even bothering to store or allow for storing of physical addresses, which to me makes it seem like it’s THE OpenHAB approach or an OpenHAB standard/way/best practice or something like that - as it keeps repeating in the same manner.

So back to my initial question, I’d like to understand why it’s taken this route and are there any considerations for a change? As i understand that the end goal for this is to be a modular easily scalable and implementable reliable but easy to set up home automation platform …

AFAIK, there is no guidance, how to discover things in the network and what information to store. It is every binding developers choice. As for the WeMo Binding, I use UPnP discovery and store the UUID for identification. Going that way, there is no need for static IP Addresses.

1 Like

That is because the MAC is meaningless if the device is not connected to the same router/gateway/hub. I’m not even certain if the MAC is meaningful if you are going from wired to wifi on the same router/gateway.

Let’s walk down the networking stack. Let’s say we ping an address by name. That goes to the DNS server who returns the IP address. Now the pinging server says “who knows this IP?” If the device with that IP is connected to the same router it replied with its own MAC. If not, then the router replies with it’s MAC.

Given this, it’s not so much as an OH standard as it is a networking standard. Saving the MAC would only be useful and meaningful in the simplest of networking environments. In all other environments you will only get the Mac of the router for all the devices that are not on the same physical router as you.

So from this perspective, Hone Assistant is the outlier. And in a home automation context, it may make sense in some context to assume that everything is connected through the same router.

That’s not entirely correct.
If a client wants to send a packet outside its own network (defined by the network mask) the default gateway (route) is always used, and therefore there’s no need for an ARP request (besides contacting the gateway itself).

In all other environments you will only get the Mac of the router for all the devices that are not on the same physical router as you.

The ARP table should never get an entry of a host outside its own defined subnet(s)/network(s) nor should it put the gateway’s MAC address of any external/internet/other-broadcastdomain host in the ARP table because that wouldn’t make any sense.

This assuming IPv4 (ARP), NDP is the IPv6 counterpart which is similar.

I do not see any benefit of using macs. If you want to communicate, you need the ip address, so you have to configure the ip address somehow.

Btw, i have no idea about the mac adresses of my devices, but i know the ip adress, at least i can figure the type.

Additionally I am not sure if you need elevated priviliges to access the mac addresses.

@job Hey Joachim , you don’t need any privileges to get a device mac address, it’s the physical address every device has that unlike IP isn’t assigned and will be the same across all networks. They are floating around within the headers of every TCP/IP packet sent. (Network Interface layer for the TCP/IP model and Datalink layer in the OSI model) And with my method you don’t need to do anything differently or know anything additional either.

Yesterday I rewrote the whole Network binding to use MAC addresses in a way that doesn’t change anything for the user, you still need to know only the ip address or name of the device, once detected, the mac address is fetched automatically and added to the thing configuration.

However nmap is slow to rely on for all scan’s so I’m currently thinking about sticking to ip scan’s, still getting the mac address from the ARP table and adding to the config, and on the presenceDetection scan just confirm the mac address is the same as stored in config, if it isn’t then do a nmap scan, find the mac address and update the thing IP address in the config.

I believe this will allow for a much more modular platform which will not require for you to know the mac addresses, but (in most cases) get a static lease or set a static ip in teh first place. Just plug and play.

@rlkoshak I see what you’re getting at and it makes sense. However in most network configuration it’d still work and bring a bit of convenience.

In my code I made the mac address based scan optional in the binding config, I’ll try to create the functionality described in this post and once I feel happy with it, I’ll share if anyone is interested :slight_smile:



1 Like

You may want to look into MAC randomization on modern phones.

@rossko57 I haven’t encountered a phone changing it’s mac address on it’s own so far, but in that case it’d essentially be untraceable for our intentions anyway regardless of the method used…

As you don’t want to give your phone a static IP because it is mobile and joins multiple networks often, and one can not assume all networks to have the same address range.

Static IP lease, as far as I know also determines the devices mac address in order to assign the predetermined IP

And my solution is out for the same reason as the previous one.

But the fact remain that the MAC used for that packet will be there gateway’s MAC.

And exactly how many of our users would have the skill and knowledge to sniff a packet and extract the MAC from it? Not many to be sure. Though one can usually find the MAC of connected devices in the gateway config, but by the time you are there, why not user standard networking practices and assign static dhcp leases?

Does this work with .things file defined Things? If I have to define a Thing with an IP address in the first place, what does this but me? What if I want to change the thing to point to a new device with the same IP (e.g. replaced a failed RPi?

Is nmap readily available on Windows and Mac? I know it isn’t available in the Docker container.

I could see this being useful, though again only for devices on the same subnet and connected to the same physical router.

I would hope that the sharing would take the formatting of a PR too the original, assuming all the edge cases are handled.

I’ve seen this more on the BT side. I’ve not encountered it on the wifi side yet.

This is correct. Static dhcp leases and MAC whitelisting would be impossible.

My cable provider gave me a router with very limited customization options. To avoid having another router(space and power issue) I keep using it, however I can not see device name, nor set static IP addresses. So for me it would be nice to use MAC addresses to avoid to manually change IP addresses of all my connected devices once a year or so, when the router decides to assign new IP’s to the devices.

1 Like

I agree MAC-address should be used on DHCP environment. Normal home automation network all devices are in the same LAN thus can be MAC-addressed.

Now I have a problem that installed binding wants to have IP-address in xxx.cfg -file. I do not want to enter IP-address because it can be changed. I want to give MAC-address and then OpenHAB should be responsible of arp-pinging for MAC=>IP conversion, and hand over found IP to binding. I don’t want to maintain manually ip-addressing of 10-20 different home devices. I am fine entering once the MAC-address to a list.

With arp-scan I can find my devices and arp-scan’s mac-vendor.txt I can name my devices. But I’ve not found way to feed that to OpenHabian and for example Denon binding to automatically find IP of my Denon amplifier.


My vote for MAC based lookup & configuration… as @joriws states, most home (key term - home) automation hubs are relatively simple networking and MAC addresses would be more “stable”.



1 Like

A possible solution?:
I’m completly new to openHab (not a handful of days since installation), but I came across the similar problem, due to my celluar phone doesnt work with static IP’s, it even avoids to connect to the router if I turn of the DHCP for static IPs.

After searching a lot…
What if simply use a single line “things” with the IP of the desired phone. OH2 seams to parse these files realy frequently.
Now via cronjob one might run something like “arp-scan”, bearing in mind one knows the MAC address of the desired device. Now cut (awk/sed/grep/left…) the “acrual DCHP given IP” and (over-)write it to that single line mobile.things ?

why don’t you reserve the IP for your mobile phone on your DHCP server?

which binding are you currently using?

I don’t think that any binding developer will modify the code of the binding to cover an edge case which is caused by networking problems outside OH2.

Of course, reply #2 always applies.

example for the required cron job:

echo “Thing Network blabla… hostname=” arp-scan -l | grep -i "00:00:00:00:00:00" | cut -f1"

Just the basic idea without any error correction

1 Like

The mobile doesnt accept a static IP provided by the router. It ONLY works / connects with active DHCP.
My other local devices dont have this problem, they’re fine using static IP

find the nearest trashcan, open it, throw the device with force down in the bin
alt: develop code to cover your edge case

Isnt it simpler to find a workaround others can also make use of?
Like (basic concept) written above ?
Much cheaper, one only needs to think about :slight_smile: