Python code to find : device name, device IP address, hexadecimal IP address and device mac address.

import socket
import uuid

hostname = socket.gethostname()
IPAddr = socket.gethostbyname(hostname)
hexIP = socket.inet_aton(IPAddr).hex()
macAddr = ':'.join(['{:02x}'.format(
    (uuid.getnode() >> elements) & 0xff)
    for elements in range(0,2*6,2)][::-1])

print("Your Computer Name is: " + hostname)
print("Your Computer IP Addreress is : " + IPAddr)
print("Your Computer hex IP is: " + hexIP)
print("Your Computer Mac Address is: " + macAddr)

Output:

Your Computer Name is: ankita-ubuntu
Your Computer IP Addreress is : 192.168.1.8
Your Computer hex IP is: c0a80108
Your Computer Mac Address is: 61:85:17:5e:7b:ef

Leave a comment

Start a Blog at WordPress.com.

Up ↑

Design a site like this with WordPress.com
Get started