MAC address generator in python

后端 未结 4 1459
时光说笑
时光说笑 2021-02-15 16:03

For purpose of creating bulk virtual machines, I need to create a random MAC address generator in Python. I don\'t know how to generate random MAC addresses.

Is the foll

4条回答
  •  我在风中等你
    2021-02-15 16:37

    Since uniqueness is all you should care about (beyond making the address well-formed), I'd worry about the MSBs in the OUI and use a sequence in the NIC specific bytes. The distribution of the addresses is likely unimportant to your application (even though some NIC or switch implementations might use them as an input to a hash, this is likely not to be a big concern).

    You may want to consider using the "locally administered" flag in the OUI to avoid a conflict with an existing device manufacturer.

    Avoid pitfalls like setting the multicast bit (your example does).

提交回复
热议问题