Changelog¶
NOTE: if any changes significantly impact your project or use case, please open an issue on GitHub or email me (see git commit author info for address).
Announcement: Compatibility with Python versions older than 3.8 (2.7, 3.4, 3.5, 3.6, 3.7) is deprecated and will be removed in getmac 1.0.0. If you are stuck on an unsupported Python, consider loosely pinning the version of this package in your dependency list, e.g. getmac<1.0.0 or getmac~=0.9.0.
1.0.0 (TBD)¶
Added¶
Rewrote documentation and published on GitHub Pages: https://ghostofgoes.github.io/getmac/index.html
Support Python 3.10 - 3.14
New function,
getmac.get_default_interface(), which returns the name of the system’s default interface (NOTE: Windows is not supported currently).Support for ipaddress objects from the Python standard library:
IPv4Address,IPv4Interface,IPv6Address,IPv6InterfaceThese can be used with the
ipandip6arguments toget_mac_address()The
ipargument will accept IPv6 objects and process them as ifip6was set.If passed a string,
ipwill still treat it like a IPv4 address. This behavior may change in a future release, withipallowing either type of address, andip6argument being deprecated.IPv4NetworkandIPv6Networkwill result in aValueError. They’re networks, not hosts, and passing them makes no sense.
Handle
bytesvalues forinterface,ip,ip6, andhostnamearguments toget_mac_address(). This will just calldecode("utf-8")on the bytes. This is to ease usage with certain libraries and functions that return strings as bytes.If you pass it some weird bytes that aren’t decodable as utf-8, it’s obviously going to break. Don’t be dumb :)
Added manpage for the command line interface (
getmac.1)Improved HP-UX support
New method,
LanscanIface, a proper implementation oflanscan -iafor HP-UX systems. This replaces the functionality of the removedUuidLanscanmethod, and is loosely based on CPython’suuid._lanscan_getnode()implementation.Added platform detection for HP-UX and a default to
lan0interface
Changed¶
BREAKING CHANGE: refactored how settings are handled. Instead of module-level globals, they’re implemented in a Settings singleton in
getmac.settings. For example,getmac.getmac.PORTshould now begetmac.settings.PORT.BREAKING CHANGE:
RuntimeErroris now raised in cases where no methods are found matching the type of request and platform, or if all matching methods fail to test. This should almost never happen unless you’re on an exotic platform or have an unusual configuration, or a recent platform update changed commands such that getmac no longer functions. If you encounter aRuntimeErrorexception, it means something went horribly wrong, and you should considor reporting the issue on GitHub.Reduce size of wheel distribution (
.whlfile)
Removed¶
Removed support for Python 2.7 - 3.7. Most of the tooling used by getmac no longer works with 3.7 and older. If you need to use one of these versions, pin to
getmac<1.0.0.Removed support for Jython. As of Dec 2025, Jython still does not support Python 3. If and when it supports Python 3, I’ll re-add support for it.
Removed support for IronPython. IronPython3 exists, however I don’t have a way to test it in CI. If someone knows of a way to test it in GitHub actions, let me know, and I’m happy to re-add support.
Removed RPM packaging, as it hasn’t been maintained since 0.6.0.
Removed
UuidArpGetnodemethod. It’s quite slow (performs up to 3 subprocess calls internally) and the functionality is already implemented byArpVariousArgs.Removed
UuidLanscanmethod. This has been replaced with the newLanscanIfacemethod. Some UUID internal function names changed with Python 3.9, and it made more sense to implement from scratch in getmac instead of continuing to rely on CPython-specific private functions.
Dev¶
Switched to PDM for project management
Added
pyproject.tomland consolidated the configurations for most toolsRemoved
setup.py,MANIFEST.in,requirements*.txt,tox.ini
Switched to CodeCov from Coveralls
Refactored source code documentation and added an API reference to the docs
Use Ruff’s formatter instead of Black and isort
0.9.5 (07/15/2024)¶
Changed¶
Fixed macOS arp when MAC has one character sections in specific cases (Fixes issue #92)
0.9.4 (06/01/2023)¶
Added¶
Support BusyBox’s
arping
Changed¶
Improve how ARP is handled. If
ArpFilemethod succeeds, use it instead ofArpingHost(this should fix #86, for realsies this time).Speed up the first call to
ArpingHostFix FORCE_METHOD not being respected for IPv4 macs
0.9.3 (03/16/2023)¶
Changed¶
Fix
ArpFilemethod being used for IPv6 (/proc/net/arp, and ARP in general, is IPv4-only)
0.9.2 (02/03/2023)¶
Changed¶
Fix flakiness with UuidArpGetNode on MacOS by making it the last method attempted (Fixes issue #82)
0.9.1 (01/24/2023)¶
Changed¶
Deprecate Python 3.6 support (support will be removed in getmac 1.0.0)
Dev¶
Fix links in README and PyPI metadata to use “main” instead of “master” for primary branch
Remove “Documentation” link from PyPI (the ReadTheDocs site is broken and hasn’t been updated since 0.5.0)
Add PyPI classifiers for 3.10 and 3.11
Some cleanup of CHANGELOG
0.9.0 (01/23/2023)¶
This release is a complete rewrite of getmac from the ground up. The public API of getmac is unchanged as part of this rewrite. get_mac_address() is still the primary way of getting a MAC address, it’s just the “under the hood” internals that have changed completely.
It’s passing tests and seems to be operable. However, with a change this large there are inevitably issues that the tests or I don’t catch, so I’m doing a series of pre-releases until I’m 99% confident in it’s stability. Refer to docs/rewrite.md for a in-depth explanation of the rewrite changes.
The new system has a number of benefits
Reduction of false-positives and false-negatives by improving method selection accuracy (platform, validity, etc.)
Significantly faster overall
“Misses” have the same performance as “Hits”
Easier to test, since each method can be tested directly via it’s class
Easier to type annotate and analyze with mypy
Easier to read, improving reviewability and ease of contributing for newcomers
Extensible! Custom methods can be defined and added at runtime (which is perfect if you have some particular edge case but aren’t able to open-source it).
Added¶
Fully support Python 3.9 (automated tests in CI)
Tentatively support Python 3.10 and 3.11 (unable to test due to the need to be able to still test 2.7)
Added default interface detection for MacOS (command:
route get default)Added initial support for Solaris/SunOS. There were a few existing methods that worked as-is, so just added indicators that those methods support
sunos(Which applies to any system whereplatform.system() == SunOS).arping(POSIX) orSendARP(Windows) will now always be used instead of sending a UDP packet when looking for the MAC of a IPv4 host, if they’re available and operable (otherwise, UDP + ARP table check will be used like before).The amount of time taken to get a result (in seconds) will now be recorded and logged if debugging is enabled (
DEBUG>=1or-d)Added command line argument to override the UDP port for network requests:
--override-port(this was already possible in Python viagetmac.getmac.PORT, but wasn’t configurable via the CLI. Now it is!).Added ability to override the detected platform via
--override-platformargument (CLI) orgetmac.getmac.OVERRIDE_PLATFORMvariable (Python). This will force methods for that platform to be used, regardless of the actual platform. Here’s an example forcinglinuxto be used as the platform:getmac -i eth0 --override-platform linux. In version 1.0.0, this feature will added as an argument toget_mac_address().Added ability to force a specific method to be used via
--force-methodargument (CLI) orgetmac.getmac.FORCE_METHODvariable (Python). This is useful for troubleshooting issues, general debugging, and testing changes. Example:getmac -v -dddd --ip 192.168.0.1 --force-method ctypeshost
Changed¶
Complete rewrite of
getmacfrom the ground up. Refer todocs/rewrite.mdfor a in-depth explanation of the rewrite changesFixed a failure to look up a hostname now returns
None, as expected, instead of raising an exception (socket.gaierror).Fixed numerous false-negative and false-positive bugs
Improved overall performance
Performance for cases where no MAC is found is now the same as cases where a MAC is found (speed of “misses” now equals that of “hits”)
Improved the reliability and performance of many methods
Fixed
netstaton older Linux distros (such as Ubuntu 12.04)Overhauled
ifconfigparsing. It should now be far more reliable and accurate across all platforms.Improved Android support. Note that newer devices are locked down and the amount of information that’s obtainable by an unprivileged process is quite limited (Android 7/9 and newer, not sure exactly when they changed this, I’m not an Android guy). That being said, the normal Linux methods should work fine, provided you have the proper permissions (usually,
root).Fixed bug with
/proc/net/routeparsing (this affected Android and potentially other platforms)Improve default interface detection for FreeBSD (command:
route get default)
Removed¶
Removed man pages from distribution (
getmac.1/getmac2.1). They were severely out of date and unused. May re-add at a later date.
Dev¶
Migrate CI to GitHub Actions, remove TravisCI and Appveyor
Add flake8 plugins:
flake8-pytest-styleandflake8-annotationsAdd additional samples and tests for WSL1 (with the Ubuntu 18.04 distro)
Add additional samples for Windows 10
Add additional samples for MacOS
Add samples and tests for Ubuntu 12.04
Add samples for NetBSD 8 (support coming in a future release)
Add samples for Solaris 10 (support TBD)
Add samples for several versions of Android
Add new tests
Improve existing tests
Consolidate everything related to RPM packaging to
packaging/rpm/. This stuff hasn’t been updated since 0.6.0, may remove in the future and leave distro packaging to distro maintainers.
0.8.3 (12/10/2021)¶
Changed¶
Added support for Thomas Habets’ version of
arpingin addition to the existing iputils one (contributed by Ville Skyttä (@scop) in #52 and #54)Added support for docker in network bridge mode (contributed by Tomasz Duda (@tomaszduda23) in #57)
Add CHANGELOG URL to PyPI metadata (contributed by Ville Skyttä (@scop) in #58)
Fixed code quality test suite errors (includes changes by Daniel Flanagan (@FlantasticDan) in #67)
Improved Android support (contributed by @emadmahdi in #71)
Minor code quality fixes (2 years of neglecting master branch)
Add Code of Conduct for project contributors
Add SECURITY.md for reporting security issues (e.g. vulnerabilities)
Deprecate Python 3.4 and 3.5
Issue deprecation message as a warning in addition to a log message
0.8.2 (12/07/2019)¶
Changed¶
Added warning about Python 2 compatibility being dropped in 1.0.0
Officially support Python 3.8
Documented a known issue with looking up IP of a local interface on Linux/WSL (See the “Known Issues” section in the README)
Added remote host lookup using
arpingas last resort
Dev¶
Standardized formatting on Black
Lint additions:
vulture, several Flake8 pluginsPinned test dependencies (pytest 5 dropped Python 2 support)
Various quality-of-life improvements for contributors/developers
0.8.1 (05/14/2019)¶
Changed¶
Fixed sockets being opened and not closed when
iporip6were used, which could lead to aResourceWarning(GH-42)
0.8.0 (04/09/2019)¶
Added¶
OpenBSD support
FreeBSD support
Python logging is now used instead of
print(logger:getmac)Include tests in the source distribution
(CLI) Added aliases for
--no-network-requests:-Nand--no-net(CLI) New argument:
-v/--verbose
Changed¶
Errors are now logged instead of raising a
RuntimeWarningImproved Ubuntu support
Performance improvements
Development¶
Significant increase in overall test coverage
Fixed and migrated the sample tests to
pytestAdded tests for the CLI
0.7.0 (01/27/2019)¶
Added¶
Type annotations (PEP 484)
Removed¶
Dropped support for Python 2.6
Removed the usage of third-party packages (
netifaces,psutil,scapy, andarpreq). This should improve the performance of lookups of non-existent interfaces or hosts, since this feature was punishing that path without providing much value. If you want to use these packages directly, I have a guide on how to do so on a GitHub Gist.
Changed¶
Significantly improved the performance of the common cases on Linux for interfaces and remote hosts
Improved POSIX interface performance. Commands specific to OSX will be run only on that platform, and vice-versa.
Significantly improved the speed and accuracy of determining the default interface on Linux
Python 2 will install an executor named getmac2 and Python 3 an executor named getmac so they do not conflict when both RPMs are installed on the same system (Credit: @hargoniX)
The
warningsmodule will only be imported if a error/warning occurs (improve compatibility with some freezers, notably PyInstaller)Improved system platform detection
Various other minor performance improvements
Development¶
Added unit tests for the samples (Credit: @Frizz925)
Scripts for building RPMs in the /scripts directory (Credit: @hargoniX)
Improved code quality and health checks
Include the CHANGELOG on the PyPI project page
Using
pytestfor all tests now instead ofunittest
Documentation¶
Added instructions on how to build a Debian package (Credit: @kofrezo)
0.6.0 (10/06/2018)¶
Added¶
Windows default interface detection if
network_requestis enabled (Credit: @cyberhobbes)Docker container (Credit: @Komish)
Changed¶
Changed project name to
getmac. This applies to the command line tool, GitHub, and the documentation.Use proper Python 2-compatible print functions (Credit: @martmists)
Removed¶
Support for Python 2.5. It is not feasible to test, and potentially breaks some useful language features, such as
__future__Variables PORT and DEBUG from top-level package imports, since changing them would have no actual effect on execution. Instead, use
getmac.getmac.DEBUG.
Dev¶
Added example videos demonstrating usage (Credit: @fortunate-man)
Added contribution guide
Added documentation on ReadTheDocs
Added a manpage
0.5.0 (09/24/2018)¶
Added¶
Full support for Windows Subsystem for Linux (WSL). This is working for all features, including default interface selection! The only edge case is lookup of remote host IP addresses that are actually local interfaces will not resolve to a MAC (which should be ff-ff-ff-ff-ff-ff).
Changed¶
Require
argparseif Python version is 2.6 or older
Dev¶
Updated tox tests: added Jython and IronPython, removed 2.6
0.4.0 (09/21/2018)¶
Added¶
New methods for remote host MACs
Windows:
arpPOSIX:
arpreqpackage
New methods for interface MACs
Windows:
wmic nic
DEBUG levels: DEBUG value is now an integer, and increasing it will increase the amount and verbosity of output. On the CLI, it can be configured by increasing the amount of characters for the debug argument, e.g. ‘-dd’ for DEBUG level 2.
Jython support (Note: on Windows Jython currently only works with interfaces)
IronPython support
Changed¶
Significant performance improvement for remote hosts. Previously, the average for
get_mac_address(ip='10.0.0.100')was 1.71 seconds. Now, the average is12.7 milliseconds, with the special case of a unpopulated arp table being only slightly higher. This was brought about by changes in how the arp table is populated. The original method was to use the host’spingcommand to send an ICMP packet to the host. This took time, which heavily delayed the ability to actually get an address. The solution is to instead simply send a empty UDP packet to a high port. The port this packet is sent to can be configured using the module variablegetmac.PORT.“Fixed” resolution of localhost/127.0.0.1 by hardcoding the response. This should resolve a lot of problematic edge cases. I’m ok with this for now since I don’t know of a case when it isn’t all zeroes.
Greatly increased the reliability of getting host and interface MACs on Windows
Improved debugging output
Tightened up the size of
getmac.pyVarious minor stability and performance improvements
Add LICENSE to PyPI package
Removed¶
Support for Python 3.2 and 3.3. The total downloads from PyPI with those versions in August was ~53k and ~407K, respectfully. The majority of those are likely from automated testing (e.g. TravisCI) and not actual users. Therefore, I’ve decided to drop support to simplify development, especially since before 3.4 the 3.x series was still very much a “work in progress”.
Dev¶
Added automated tests for Windows using Appveyor
Tox runner for tests
Added github.io page
Improved TravisCI testing
0.3.0 (08/30/2018)¶
Added¶
Attempt to use Python modules if they’re installed. This is useful for larger projects that already have them installed as dependencies, as they provide a more reliable means of getting information.
psutil: Interface MACs on all platformsscapy: Interface MACs and Remote MACs on all platformsnetifaces: Interface MACs on Non-Windows platforms
New methods for remote MACs
POSIX:
ip neighbor show, Abuse ofuuid._arp_getnode()
New methods for Interface MACs
POSIX:
lanscan -ai(HP-UX)
Changed¶
Certain critical failures that should never happen will now warn instead of failing silently.
Added a sanity check to the
ip6argument (IPv6 addresses)Improved performance in some areas
Improved debugging output
Fixed¶
Major Bugfix: search of
proc/net/arpwould return shorter addresses in the same subnet if they came earlier in the sequence. Example: a search for192.168.16.2on Linux would instead return the MAC address of192.168.16.254with no errors or warning whatsoever.Significantly improved default interface detection. Default interfaces are now properly detected on Linux and most other POSIX platforms with
iporroutecommands available, or thenetifacesPython module.
Dev¶
Makefile
Vagrantfile to spin up testing VMs for various platforms using Vagrant
Added more samples of command output on platforms (Ubuntu 18.04 LTS)
0.2.4 (08/26/2018)¶
Fixed¶
Fixed identification of remote host on OSX
Resolved hangs and noticeable lag that occurred when “network_request” was True (the default)
0.2.3 (08/07/2018)¶
Fixed¶
Remote host for Python 3 on Windows
0.2.2¶
Added¶
Short versions of CLI arguments (e.g. “-i” for “–interface”)
Changed¶
Improved usage of “ping” across platforms and IP versions
Various minor tweaks for performance
Improved Windows detection
Fixed¶
Use of ping command with hostname
Dev:¶
Improvements to internal code
0.2.1¶
Nothing changed. PyPI just won’t let me push changes without a new version.
0.2.0 (04/15/2018)¶
Added¶
Checks for default interface on Linux systems
New methods of hunting for addresses on Windows, Mac OS X, and Linux
Changed¶
CLI will output nothing if it failed, instead of “None”
CLI will return with 1 on failure, 0 on success
No CLI arguments now implies the default host network interface
Added an argumnent for debugging:
--debugRemoved
-doption from--no-network-requests
Fixed¶
Interfaces on Windows and Linux (including Bash for Windows)
Many bugs
Removed¶
Support for Python 2.6 on the CLI
Dev¶
Overhaul of internals
0.1.0 (04/15/2018):¶
Added¶
Addition of a terminal command:
get-macAbility to run as a module from the command line:
python -m getmac
Changed¶
arp_requestargument was renamed tonetwork_requestUpdated docstring
Slight reduction in the size of getmac.py
Dev¶
Overhauled the README
Moved tests into their own folder
Added Python 3.7 to list of supported snakes
0.0.4 (11/12/2017):¶
Python 2.6 compatibility
0.0.3 (11/11/2017):¶
Fixed some addresses returning without colons
Added more rigorous checks on addresses before returning them
0.0.2 (11/11/2017):¶
Remove print statements and other debugging output
0.0.1 (10/23/2017):¶
Initial pre-alpha