Platforms¶
This page covers which platforms getmac supports, and which methods (commands, files, and libraries) it uses to get MAC addresses on each of them.
Supported platforms¶
All or almost all features should work on “supported” platforms. While other versions of the same family or distro may work, they are untested and may have bugs or missing features.
Windows
Desktop: 7, 8, 8.1, 10, 11 (thanks @StevenLooman for testing Windows 11!)
Server: 2025, 2022
Partially supported (untested): 2000, XP, Vista
Linux distros
CentOS/RHEL 6+
Ubuntu 16.04+ (15.10 and older should work, but are untested)
Fedora (24+)
macOS (Darwin): the latest release, though macOS 14 and 13 have been tested with success.
Android (6+), with limitations. See Android.
Windows Subsystem for Linux (WSL), both WSL1 and WSL2
FreeBSD (11+)
OpenBSD
NetBSD (9.3+)
DragonFly BSD (6.4+)
Oracle Solaris 11.4
illumos distros: OmniOS (r151054+), OpenIndiana (2026.04+). Others like SmartOS should work, but are untested.
HP-UX (untested): interface lookups only, via
lanscan. I don’t have a way to test it.Docker. See Docker.
BusyBox (not technically a platform, but several of the methods work on this platform)
Linux, Windows, and macOS are tested in CI on every code change, and so are NetBSD, DragonFly BSD, Solaris, and illumos (in VMs). FreeBSD and OpenBSD are tested by hand, so help testing them is always welcome.
Methods by platform¶
getmac has a list of methods, each of which uses one command, file, or library to get a MAC. On each platform, getmac tries the methods for that platform in order, and uses the first one that works. How methods are chosen and used explains the details. The lists below are in the order the methods are tried in. Every method is documented in the API, including what it parses and any quirks.
To see which methods were chosen on your system, run getmac -v -dd.
Windows¶
- Interfaces
GetmacExe(getmac.exe),IpconfigExe(ipconfig.exe /all),WmicExe(wmic.exe)- IPv4 hosts
CtypesHost(SendARPfromIphlpapi, viactypes, sends an ARP request),ArpExe(arp.exe -a),NetshNeighbors(netsh.exe int ipv4 show neigh)- IPv6 hosts
NetshNeighbors(netsh.exe int ipv6 show neigh)- Default interface
DefaultIfaceNetsh(netsh.exe int ipv4 show route). With network requests enabled,get_mac_address()with no arguments first finds the IP of the default interface by connecting a UDP socket to1.1.1.1:53(Cloudflare’s DNS server). Then it looks that IP up as a host.netsh.exeis only used if that doesn’t find a MAC.
Linux¶
Also used on Android and WSL2 (see below).
- Interfaces
SysIfaceFile(/sys/class/net/<iface>/address),FcntlIface(fcntl.ioctl()),IfconfigWithIfaceArg(ifconfig <iface>),IfconfigOther(ifconfig, then with-a,-v, or-avif that fails),IpLinkIface(ip link),NetstatIface(netstat -iae)- IPv4 hosts
ArpFile(/proc/net/arp),ArpingHost(arping, sends an ARP request),IpNeighborShow(ip neighbor show),ArpVariousArgs(arp)- IPv6 hosts
IpNeighborShow(ip neighbor show),ArpVariousArgs(arp)- Default interface
DefaultIfaceLinuxRouteFile(/proc/net/route),DefaultIfaceIpRoute(ip route list 0/0),DefaultIfaceRouteCommand(route -n)
arping is the iputils, Habets, or BusyBox variant, and usually needs root.
WSL¶
WSL2 is a Linux VM with its own network, so it’s detected as Linux and uses the Linux methods. WSL1 (platform wsl) shares the Windows network, so it uses Linux methods for interfaces and Windows commands for hosts.
- Interfaces
SysIfaceFile,FcntlIface,IfconfigWithIfaceArg,IpLinkIface,NetstatIface- IPv4 hosts
ArpExe(arp.exe -a)- IPv6 hosts
No WSL1-specific methods yet, so the generic methods are tried (see Other platforms).
- Default interface
DefaultIfaceLinuxRouteFile,DefaultIfaceIpRoute,DefaultIfaceRouteCommand
macOS (Darwin)¶
- Interfaces
DarwinNetworksetupIface(networksetup -getmacaddress <iface>),IfconfigEther(ifconfig)- IPv4 hosts
ArpingHost(arping, if it’s installed, sends an ARP request),ArpVariousArgs(arp)- IPv6 hosts
NdpNeighbors(ndp -an),ArpVariousArgs(arp)- Default interface
DefaultIfaceRouteGetCommand(route -n get default)
FreeBSD¶
- Interfaces
IfconfigWithIfaceArg(ifconfig <iface>)- IPv4 hosts
ArpFreebsd(arp <ip>),ArpVariousArgs(arp)- IPv6 hosts
NdpNeighbors(ndp -an),ArpFreebsd,ArpVariousArgs- Default interface
DefaultIfaceRouteGetCommand(route -n get default),DefaultIfaceFreeBsd(netstat -rn)
OpenBSD¶
- Interfaces
IfconfigWithIfaceArg(ifconfig <iface>)- IPv4 hosts
ArpOpenbsd(arp -an)- IPv6 hosts
NdpNeighbors(ndp -an),ArpOpenbsd- Default interface
DefaultIfaceOpenBsd(route -nq show -inet -gateway -priority 1)
NetBSD and DragonFly BSD¶
- Interfaces
IfconfigWithIfaceArg(ifconfig <iface>)- IPv4 hosts
ArpFreebsd(arp <ip>)- IPv6 hosts
NdpNeighbors(ndp -an),ArpFreebsd- Default interface
DefaultIfaceRouteGetCommand(route -n get default)
Solaris and illumos¶
Platform sunos covers Oracle Solaris and the illumos distros (OmniOS, OpenIndiana, SmartOS). All of these methods except the ifconfig fallback work for regular users, not just root.
- Interfaces
DladmIface(dladm show-link, thenshow-phys -m,show-vnic, orshow-aggr -xdepending on the type of link),IfconfigWithIfaceArg(ifconfig <iface>, which only shows the MAC to root)- IPv4 hosts
NetstatNetToMedia(netstat -pn -f inet),ArpVariousArgs(arp)- IPv6 hosts
NetstatNetToMedia(netstat -pn -f inet6),ArpVariousArgs(arp)- Default interface
DefaultIfaceRouteGetCommand(route -n get default)
HP-UX¶
- Interfaces
LanscanIface(lanscan -ai)- Hosts and default interface
No HP-UX-specific methods yet, so the generic methods are tried (see Other platforms).
Other platforms¶
getmac falls back to generic methods that work on many Unix-like systems on a platform it doesn’t know. It does the same for a type of lookup that has no methods for the platform. It logs a warning and shows a RuntimeWarning (using warnings) when it does. Running with python -W error::RuntimeWarning turns an unsupported platform into an error, which is how the NetBSD and DragonFly CI checks it.
- Interfaces
IfconfigWithIfaceArg(ifconfig <iface>),IfconfigOther(ifconfig, then with-a,-v, or-avif that fails),IpLinkIface(ip link),NetstatIface(netstat -iae)- Hosts
IpNeighborShow(ip neighbor show),ArpVariousArgs(arp)- Default interface
DefaultIfaceIpRoute(ip route list 0/0),DefaultIfaceRouteCommand(route -n),DefaultIfaceRouteGetCommand(route -n get default)
If you’re on a platform that isn’t listed here and these work for you, or don’t, please open an issue! Adding proper support is usually straightforward, see Adding a new method.
Android¶
Android uses the Linux methods. Newer versions of Android don’t have many of the commands getmac uses, and restrict access to network information, so getmac may not find anything. Installing BusyBox or the Termux iproute2 and net-tools packages adds the missing commands, but they can still be blocked by Android’s restrictions. The normal Linux methods should work fine, provided you have the proper permissions (usually, root).
Python 3.13 and newer identify Android as its own platform (platform.system() returns "Android"). getmac treats it as Linux either way.
Known issues¶
Linux, WSL: Getting the MAC of a local interface IP does not currently work (
getmac --ip 10.0.0.4will fail if10.0.0.4is the IP address of a local interface). This issue may be present on other POSIX systems as well. Use the interface name instead.WSL1: remote IPv6 hosts aren’t supported yet.
arp.exeis used for IPv4 hosts, andnetsh.exeisn’t used on WSL1 yet.Windows:
ipconfig.exe(a fallback for whengetmac.exedoesn’t work) only finds interfaces by name in English output, since the adapter headers are translated. Adapter descriptions are found if the label is “Description” (English), and MACs are found in any language.Windows:
wmic.exeis deprecated as of Windows 10 21H1 and is being removed from Windows 11, soWmicExemay not work there. It’s the last fallback for interfaces, so this only matters ifgetmac.exeandipconfig.exeboth fail.Android: see above.
Hostnames for IPv6 devices are not yet supported.
IPv6 link-local addresses can carry a zone (
fe80::1%en0orfe80::1%2), but only macOS and the BSDs (NdpNeighbors) and Solaris and illumos (NetstatNetToMedia) use it. On Linux and Windows, pass the address without a zone.IPv6 support is good but lags behind IPv4 in some places and isn’t as well-tested across the supported platform set.