Never one to back down from a challenge, I decided to try to get the MAC address from my Raspberry Pi running Windows 10 IoT Core. It was clear to me from doing some searching that Windows Universal Apps cannot get the MAC address, but all of that advice might just be wrong.
Conventional wisdom is that we don’t need to know the MAC address because it is just a unique number, and we can get a UUID associated with our system – but that is to ignore the reasons why we might want the MAC address, which include but are not limited to:
Then I noticed a little thing, in the web interface for the Raspberry Pi it shows the MAC address for the onboard Ethernet port. Being creative I decided to figure out how it does this. It turns out that it is a simple REST API, or HTTP GET, that returns JSON data with information about the network devices.
The following code will return the MAC address of the first Ethernet device found:
String MacAddress = await GetMAC();
private async Task<String> GetMAC()
String MAC = null;
StreamReader SR = await GetJsonStreamData("http://localhost:8080/api/networking/ipconfig");
JsonObject ResultData = null;
JSONData = SR.ReadToEnd();
ResultData = (JsonObject)JsonObject.Parse(JSONData);
JsonArray Adapters = ResultData.GetNamedArray("Adapters");
//foreach (JsonObject Adapter in Adapters)
for (uint index = 0; index < Adapters.Count; index++)
JsonObject Adapter = Adapters.GetObjectAt(index).GetObject();
String Type = Adapter.GetNamedString("Type");
if (Type.ToLower().CompareTo("ethernet") == 0)
MAC = ((JsonObject)Adapter).GetNamedString("HardwareAddress");
catch (Exception E)
private async Task<StreamReader> GetJsonStreamData(String URL)
HttpWebRequest wrGETURL = null;
Stream objStream = null;
StreamReader objReader = null;
wrGETURL = (HttpWebRequest)WebRequest.Create(URL);
wrGETURL.Credentials = new NetworkCredential("Administrator", "p@ssw0rd");
HttpWebResponse Response = (HttpWebResponse)(await wrGETURL.GetResponseAsync());
if (Response.StatusCode == HttpStatusCode.OK)
objStream = Response.GetResponseStream();
objReader = new StreamReader(objStream);
catch (Exception e)
System.Diagnostics.Debug.WriteLine("GetData " + e.Message);
Copyright © 2015 – Bruce Eitman and Embedded101.com
All Rights Reserved
Hi. This no longer works for me in the iot-core custom OEM-build/FFU. They have changed the access levels somewhere and it is not debuggable either. Does anybody know how to get a real hardware-id or board-id? Anything that can uniquely identify the board across installations and reboots. I have searched high and low. Thanks!
Hi, since I am having trouble with this intervace in an OEM-custom Image/FFU scenario, I wonder, how do I get a UUID for the board? All I find is this https://msdn.microsoft.com/en-us/library/windows/apps/windows.security.exchangeactivesyncprovisioning.easclientdeviceinformation which does not give a non-mutable guid for the board as far as I can tell. THANKS!
Hi Bruce, Good to know you are playing with Windows 10 IoT, and thanks for sharing these great finding.
Re: Windows 10 IoT Core: Getting the MAC Address from Raspberry Pi
Hi. This no longer works for me in the iot-core custom OEM-build/FFU. They have changed the access levels...
Hi, since I am having trouble with this intervace in an OEM-custom Image/FFU scenario, I wonder, how...
Re: Windows 10 IoT Core: Shutdown and Reboot the Raspberry Pi
I like your project here, and I've used it, and at one time it worked, at least with an older version...
-- David Jones
Hi Bruce, Good to know you are playing with Windows 10 IoT, and thanks for sharing these great finding...
-- Samuel Phung