Fork me on GitHub

Project Notes

Generating Random MAC Addresses

Delving into MAC addresses and a little script to generate random ones.

About MAC Addresses

A media access control address (MAC address), also called physical address, is a unique identifier assigned to network interfaces for communications on the physical network segment (wikipedia)

MAC-48 defines the familiar 48-bit sequence (00-16-3e-53-79-a8) that comprises two parts:

  • 24 bit organisational identifier (OUI) that is assigned by the IEEE Registration Authority
  • 24 bit network interface controller (NIC) that is assigned by the manufacturer

MAC-48 is now subsumed within the EUI-48 scheme, which has more general application beyond network interfaces. There is a 64-bit EUI-64 scheme which should be more future-proof, and is used with IPv6 for example.

There are specific MAC addresses and ranges reserved for multicast and broadcast.

MAC in Ethernet

MAC source and destination addresses appear in the Ethernet frame header.

Conceptually, the media access control layer is the lower sublayer of the data link layer (layer 2) of the seven-layer OSI model.

A Little Random MAC Generator

random_mac.py generates a random MAC using the Xensource, Inc. OUI by default unless you pass it to a specific OUI on the command line:

$ python test_random_mac.py
....
----------------------------------------------------------------------
Ran 4 tests in 0.001s

OK
$ python random_mac.py
00-16-3e-53-79-a8
$ python random_mac.py 11-22-33
11-22-33-5c-74-54

MAC Vendor Lookup

As well as the IEEE Registration Authority itself, there are any number of sites where youj can lookup official assigned numbers, including:

Credits and References

About LCK#74 python
Project Source on GitHub Return to the Project Catalog

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.