info_i_25x25.png See important information about Ubiquiti Devices and KRACK Vulnerability in this article. We will update this document as more information becomes available.

UniFi - BSSID to MAC Mapping

 Overview


This article describes the logic between the BSSID (Basic Service Set Identifier) and MAC address of the radio.

Notes & Requirements
- Firmware Version Applicable: UAP Firmware 3.7.37+
- Device Models Applicable: Gen1, Gen2, Gen 3 UAPs, excluding the Broadcom based models. (See what Generation your UAP is here)

Table of Contents


  1. Introduction
  2. Sample Code
  3. Related Articles

Introduction


Back to Top

An access point uses multiple MAC addresses for layer 2 communication on the different interfaces. The MAC address of a wireless interface is called the Basic Service Set Identifier (BSSID). A wireless access point needs a way to dynamically create those BSSIDs as it can have different numbers of SSIDs. In general, each radio and network interface has a globally unique MAC address programmed when the AP leaves the factory. Software uses that base MAC address to derive the BSSID using the following logic:

  • The first SSID uses the default hardware MAC of the radio
  • Every subsequent SSID sets the U/L bit (bit 1 of the first octet) to 1, indicating a locally administered MAC address. In addition, it increments the most-significant 4 bits of the first octet by (SSID index - 2).

For example, an AP with MAC address 80:2a:a8:17:74:b5 and 4 SSIDs: SSID1, SSID2, SSID3, SSID4 would use the following mapping:

SSID1 -> 80:2a:a8:17:74:b5

SSID2 -> 82:2a:a8:17:74:b5

SSID3 -> 92:2a:a8:17:74:b5

SSID4 -> a2:2a:a8:17:74:b5

Note that this MAC address, 80:2a:a8:17:74:b5, is the MAC of the radio broadcasting those SSIDs, and does not correspond to the MAC address of the wired ethernet port. The ethernet port is usually close by (i.e. modification of one of the octets by 1 or 2, depending on the number of radios), but it is not defined which octet gets modified.


Sample Code


Back to Top

Following is a code example in Python on how to quickly map a BSSID to the radio’s MAC address:

def get_mac(_bssid):
macbytes = [int(i, 16) for i in _bssid.strip().split(":")]
UBNT_OUIs = [
[  0x00, 0x15, 0x6d ]
,[  0x00, 0x27, 0x22 ]
 ,[  0x04, 0x18, 0xd6 ]
    ,[  0x24, 0xa4, 0x3c ]
     ,[  0x44, 0xd9, 0xe7 ]
   ,[  0x68, 0x72, 0x51 ]
,[  0x78, 0x8a, 0x20 ]
    ,[  0x80, 0x2a, 0xa8 ]
     ,[  0xb4, 0xfb, 0xe4 ]
      ,[  0xdc, 0x9f, 0xdb ]
      ,[  0xf0, 0x9f, 0xc2 ]
 ,[  0xfc, 0xec, 0xda ]
]

for oui in UBNT_OUIs:
       if (macbytes[1]==oui[1] and macbytes[2]==oui[2]):
           macbytes[0] = oui[0]

   return ":".join(["{:02x}".format(i) for i in macbytes])

Related Articles


Back to Top

UniFi - Which hardware generation is my UniFi Access Point (UAP)?