Gethostbyaddr() Function In Python

Function Name:



Function Signature:



Function Overview:

Given an IP address the function socket.gethostbyaddr() returns a tuple containing

  • Host Name
  • Alias list for the IP address if any
  • IP address of the host



import socket


ipAddress = ""

hostName = socket.gethostbyaddr(ipAddress)

print("Host Name for the IP address {} is {}".format(ipAddress, hostName))



Host Name for the IP address is ('', [''], [''])


Copyright 2024 ©