#encoding=utf-8 import random def randomMac(): macstring = "0123456789abcdef"*12 macstringlist=random.sample(macstring,12) return "{0[0]}{0[1]}:{0[2]}{0[3]}:{0[4]}{0[5]}:{0[6]}{0[7]}:{0[8]}{0[9]}:{0[10]}{0[11]}".format(macstringlist) print randomMac() def randomIP(): a= random.sample(range(1,256)*4, 4) b= map(str,a) return '.'.join(b) print randomIP()