Generating a random MAC address
Negating an argument is somewhat counterintuitive. Consider passing them as multicast and local instead.

I would seriously consider defining
  UNIVERSAL = 0x01
  MULTICAST = 0x02

and pass them as a single argument, is in
      random_mac(UNIVERSAL | MULTICAST)


Using both randint and randrange feels odd. I would stick with randrange.

First octet needs a special treatment anyway. That said, consider
  def random_mac(special_bits = 0):
      octets = [randrange(OCTET_VALUE) for _ in range(N_MAC_OCTETS)]
      octets[0] = fix_octet(octet[0], special_bits)
      return &quot;:&quot;.join(f&quot;{octet:02X}&quot; for octet in octets)

with
  def fix_octet(octet, special_bits):
      return (octet &amp; ~0x03) | special_bits