Change IP to Number
import struct
import socket
def ip2num(addr):
try:
num = struct.unpack('!I', socket.inet_aton(addr))[0]
except Exception as e:
num = -1
return num
Change MAC to Number
mac='34-02-86-F8-8D-50'
n = int(mac.replace('-', ''), 16)
Change Number to MAC
MAC = hex(n)