skillfed

getmac

Get MAC addresses of remote hosts and local interfaces

getmac v0.9.5 385.8K downloads/30d#7,059 on PyPI89
Permissive license MIT Active released

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 getmac

uv

uv add getmac

poetry

poetry add getmac

Installing 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

Development Status :: 4 - BetaEnvironment :: ConsoleIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: MIT LicenseOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: OS IndependentOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 2Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: IronPythonProgramming Language :: Python :: Implementation :: JythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python ModulesTopic :: System :: NetworkingTopic :: System :: Systems AdministrationTopic :: Utilities

Tags

get mac address network interfacemac address lookup remote hostlayer 2 address resolutionarp table mac addresspure python mac addresscross-platform mac addressnetwork interface mac address
network-diagnosticsmac-addresscross-platform

More Libraries packages