Skip to main content

randmac.py

randmac is a utility that generates 12-digit mac addresses; either the NIC portion or full 12-digit MAC.

By default randmac returns a random 12-digit MAC address in the locally administered address (LAA) unicast format. This means you will always see x2, x6, xA, or xE at the beginning of a MAC address generated by randmac. With -p, it keeps the vendor (OUI) portion of the MAC you pass in and randomizes only the NIC portion.

The output uses the same separator and lettercase as the MAC you pass in.

Installation

To install with pip:

python3 -m pip install randmac

Requirements

Python 3.13 or greater is required.

Supported MAC address formats

Supported formats:

  • MM:MM:MM:SS:SS:SS (colons)
  • MM-MM-MM-SS-SS-SS (hyphens/dashes)
  • MM.MM.MM.SS.SS.SS (dots/periods)
  • MMMM.MMSS.SSSS (cisco style)
  • MMMMMMSSSSSS (no separator)

where M stands for the manufacturer or vendor, and S stands for the NIC specific portion.

Usage

usage: randmac [-h] [-p] [-v] [mac]

Generates MAC addresses. By default randmac will generate a 12-digit MAC
address following the Locally Administrated Address (LAA) format. randmac only
supports 12-digit (48-bit) MAC addresses.

positional arguments:
  mac                sample MAC address that sets the output format (and the
                     vendor portion with -p)

options:
  -h, --help         show this help message and exit
  -p, --partial      randomizes the NIC portion of a MAC address
  -v, -V, --version  show program's version number and exit

In your own code, you can from randmac import RandMac and use it like RandMac(). If you wish to change the mac address format, pass in a sample MAC address with the target format. This means you can from randmac import RandMac and use it like RandMac("0000.0000.0000") or RandMac("ff-ff-ff-dd-dd-dd") to specify the delimiter format.

From a terminal (if the console scripts entry point randmac is in your path and executable) you can type randmac and press enter to generate a new 12-digit LAA address, or randmac 00:00:00:00:00:00 -p to generate a MAC with the same OUI, but a different NIC portion. The result will look something like 00:00:00:60:cf:6e.

Example usage

From Python:

>>> from randmac import RandMac
>>> RandMac()
'a6:9b:6b:8e:b3:42'
>>> RandMac("00:00:00:00:00:00", True)
'00:00:00:3f:8a:06'
>>> RandMac("0000.0000.0000", True)
'0000.007c.e662'
>>> RandMac("AA-BB-CC-DD-EE-FF")
'06-EB-45-84-D1-E3'

From CLI:

> randmac
fa:bf:7c:5d:65:3e
> randmac 00-00-00-00-00-00 -p
00-00-00-dd-5f-16

License

The license for this project can be found here.

Metadata

Release files for randmac 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for randmac 0.2.0
File Size Uploaded Provenance
randmac-0.2.0.tar.gz 8.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for randmac 0.2.0
File Interpreter ABI Platform
randmac-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.7 kB

Release files / randmac-0.2.0.tar.gz

Download URL randmac-0.2.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
03eab5a1f1a93d8f95ceb531c830c87848b20032503b68274267514404537a10
BLAKE2b-256 checksum
How to use checksums
97cb909528b4f9a2bd58def72f758e4c3b78f632ebcb4cfc804fe8a02f09923b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / randmac-0.2.0-py3-none-any.whl

Download URL randmac-0.2.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ea7222a1777ee1d3e7f7f7389641ffc7ca4d07018753fbfabb970780243afe04
BLAKE2b-256 checksum
How to use checksums
cd0b448402fb679acbb51cca2da622338cbe707917e9930a5007ac974757628e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for randmac 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for randmac-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page