Registry / http-networking / getmac

getmac

JSON →
library0.9.5pypypi✓ verified 35d ago

getmac is a cross-platform Python library designed to reliably retrieve the MAC addresses of local network interfaces and remote hosts. The current version is 0.9.5, and it maintains a regular release cadence, providing minor updates with bug fixes and improvements every few months.

http-networking
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

from getmac import get_mac_address

Demonstrates how to retrieve the local machine's MAC address, and optionally, how to fetch the MAC address for a specific interface or a remote IP.

from getmac import get_mac_address # Get the MAC address of the first available local interface mac_address = get_mac_address() print(f"Local MAC Address: {mac_address}") # Optionally, get MAC for a specific interface (e.g., 'eth0' or 'en0') # interface_mac = get_mac_address(interface='eth0') # if interface_mac: # print(f"MAC for eth0: {interface_mac}") # Optionally, get MAC for a remote IP address (requires ARP access) # remote_ip = '192.168.1.1' # Replace with a reachable IP # remote_mac = get_mac_address(ip=remote_ip) # if remote_mac: # print(f"MAC for {remote_ip}: {remote_mac}")
getmac --version
Debug
Known footguns
breakingCompatibility with Python versions 2.7, 3.4, 3.5, and 3.6 will be completely removed in `getmac` 1.0.0. If your project relies on these older Python environments, you must pin your `getmac` dependency to `<1.0.0` (e.g., `getmac~=0.9.0`) to prevent breakage upon upgrade.
gotchaVersion 0.9.0 was a 'complete rewrite' of the library. While the public API aimed for backward compatibility, significant internal refactoring occurred. Users upgrading from versions prior to 0.9.0 should conduct thorough testing, as behavioral changes or differences in how MAC addresses are resolved in edge cases might occur.
gotchaMAC address retrieval is highly dependent on the operating system, network configuration, and available system utilities. `getmac` has a history of fixing platform-specific issues (e.g., macOS ARP, BusyBox arping, IPv6 handling). Inconsistent or unexpected results may arise on certain OS/network environments; consider specifying `interface` or `ip` for more targeted queries and robust error handling.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources