forked from smilejay/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandomMAC.py
More file actions
22 lines (17 loc) · 556 Bytes
/
randomMAC.py
File metadata and controls
22 lines (17 loc) · 556 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/python
# *-* coding:utf-8 *-*
import random
def randomMAC():
'''
generate random MAC address.
the first 24 bits are for OUI (Organizationally Unique Identifier).
OUI是由IEEE的注册管理机构给不同厂家分配的代码,区分了不同的厂家。
'''
mac = [0x00, 0x8c, 0xfa,
random.randint(0x00, 0xff),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff)
]
return ':'.join(map(lambda x: "%02x" % x, mac))
if __name__ == '__main__':
print randomMAC()