I need to find the MAC address of the Network Interface Card which is assigned the default route in python. with Python. For now i tried solution:
process = os.popen('wmic nic get MACAddress')
result = process.read()
process.close()
print result.split(" \r\n")[1:-1][0]
or:
from uuid import getnode as get_mac
':'.join(("%012X" % mac)[i:i+2] for i in range(0, 12, 2))
It's working when i have only 1 lan, but when i have some wmware adapter with some MAC, sometime i get that MAC.
How to get the MAC Address of the default route?
As @fyrelinx stated there is no "REAL" MAC address, but you can get the interface with the default route via the command line of your operating system using sub process module, the next command works on OSX:
Then you can get the mac address of that particular interface ('en1' in my case) using netifaces on pypi as seen in this discussion: