Scapy - get my own MAC address

aviran picture aviran · Jun 1, 2013 · Viewed 8.5k times · Source

How do I get the MAC address of the interface I am sending packets with?

I am trying to create a custom ARP packet, and I need to include my own MAC in it. I can not seem to find a way to get it.

Answer

Koreth picture Koreth · Jun 1, 2013

Take a look at the get_if_hwaddr() function.

Doc: https://scapy.readthedocs.io/en/latest/routing.html

This code may help you :

my_macs = [get_if_hwaddr(i) for i in get_if_list()]

Cheers, K.