Learn to Code via Tutorials on Repl.it!

← Back to all posts
Find IP and MAC with Python!
TristanMisja (36)

Getting MAC Address

To get the MAC of your device, you need the re and uuid modules.
Its simple, only 2 lines of code at the least.

import re, uuid

MAC = ':',join(re.findall('..', '%012x' % uuid.getnode()))

See? Simple.

Getting IP Address

For this, you will need the socket module.

import socket

IPAddr = socket.gethostbyname(socket.gethostname())


There you go! Sorry that it is short. If you like this, please upvote. If you have ideas, comment them!