Convert IP Address to Hostname using Python

socket library

import socket

ip = '8.8.8.8'
hostname = socket.gethostbyaddr(ip)[0]

print(hostname)

Leave a Comment

Cancel reply

Your email address will not be published.