getmac
Get MAC addresses of remote hosts and local interfaces
What it is and what it does
getmac is a pure-Python library that retrieves MAC (Media Access Control) addresses from local network interfaces and remote hosts on the same LAN. It provides a single function, `get_mac_address()`, that accepts either an interface name, IPv4/IPv6 address, or hostname and returns the corresponding MAC address. The package works across Windows, macOS, Linux, BSD, and other POSIX systems without requiring compiled C extensions.
The library handles remote host lookups by querying the system's ARP (Address Resolution Protocol) or NDP (Neighbor Discovery Protocol) table. For hosts not yet in the table, it can optionally send a UDP packet to populate the table first. It also offers a command-line tool for one-off lookups and supports Python 2.7 and 3.4 through 3.11, making it suitable for legacy and modern codebases alike.
Use it for:
- Identify which physical network interface a service is bound to by retrieving its MAC address for logging or diagnostics.
- Resolve a remote host's MAC address on the LAN for network inventory, device discovery, or ARP spoofing detection.
- Build a cross-platform network diagnostic tool that needs MAC addresses without adding C-extension dependencies.
- Populate a local device database by querying MAC addresses of known hosts on a corporate network.
- Implement network-based device authentication or access control that keys off MAC addresses.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Retrieves MAC addresses of local network interfaces and remote hosts on the LAN via a single pure-Python function, with no compiled dependencies.
Yes. getmac is lightweight, dependency-free, actively maintained, and covers a genuine need for cross-platform MAC address lookup without C extensions. It is well-suited for network diagnostics, device discovery, and inventory tasks. The trade-off is that it relies on ARP/NDP tables and may be slower than C-based alternatives like psutil for high-volume queries, but for typical use cases the simplicity and portability outweigh that cost.
Install
getmac on PyPI
pip
pip install getmacuv
uv add getmacpoetry
poetry add getmacInstalling getmac
Before you install
Low friction: pure-Python wheel with zero runtime dependencies and a small footprint. Actively maintained as of August 2026 with recent commits; suitable for production use.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install getmac
from getmac import get_mac_address
# Get MAC of a local interface
eth_mac = get_mac_address(interface="eth0")
# Get MAC of a remote host by IP
ip_mac = get_mac_address(ip="192.168.0.1")
Remote host MAC lookup requires the ARP/NDP table to be populated; by default getmac sends a UDP packet to the target (port 55555) to trigger this, which can be disabled with network_request=False.
Verify before relying
- Relative performance compared to alternatives like psutil or netifaces in typical workloads
- Success rate of MAC resolution across different network topologies and configurations
- Whether Python 3.10+ support is tested in CI or only claimed to work
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 759 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 385,828/month — #7,059 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: getmac-0.9.5-py2.py3-none-any.whl
Keywords: getmac, get-mac, macaddress, mac-address, mac, ethernet, mac-48, networking, network, networking, layer2, layer-2, 802.3
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
aiodiscoverDiscovers hosts on a local network by…
permissive · top 15,000 on PyPI
netifaces-plusRetrieves network interface information…
permissive · top 15,000 on PyPI
netifaces2Retrieves network interface information…
permissive · top 15,000 on PyPI
netifacesProvides portable access to network interface…
permissive · top 5,000 on PyPI
ifaddrEnumerate network interfaces and their IP…
permissive · top 5,000 on PyPI
ifcfgIfcfg parses network interface configuration…
permissive · top 15,000 on PyPI
wakeonlanSends wake-on-LAN magic packets to power on…
permissive · top 15,000 on PyPI
randmacGenerates random 12-digit MAC addresses in…
permissive · top 15,000 on PyPI
macaddressParses, validates, and converts MAC addresses…
permissive · top 15,000 on PyPI
mac-vendor-lookupResolves MAC addresses to vendor names using a…
permissive · top 15,000 on PyPI