Get Mac address in python scripts

Joe Abley jabley at
Mon Aug 12 18:07:27 UTC 2019

Hi Michel,

On 12 Aug 2019, at 13:54, dy1977--- via Unbound-users <unbound-users at> wrote:

> I highly appreciated the flexibility given by python scripts in Unbound. Since I want to take decisions based on user, I used the code given in the examples to get the IP address of the sender. No problem. But what I would really need is the MAC address. I have not found anything about that in Google or by exploring the code of Unbound.
> Is there any possibility to get the MAC address in the python scripts ? Or will I have to patch the code of Unbound ? In this last case, if anyone knows where in the code I should investigate, or even better propose the code, I would highly appreciate.

In order to get the MAC address corresponding to a particular layer-3 address you will need to consult the ARP table (IPv4) or NDP/SEND tables (IPv6) on a device attached to the same subnet as the device with that IP address. This is not a restriction of unbound, but rather just how IP works.

In the case of a home gateway that might be the same device as is running unbound, but in other cases (e.g. where an unbound instance is used by devices spread over a more elaborate network topology) it might not be.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: Message signed with OpenPGP
URL: <>

More information about the Unbound-users mailing list