Function Name:
gethostbyaddr
Function Signature:
gethostbyaddr(ip_address)
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
Example:
import socket
ipAddress = "192.0.43.8" hostName = socket.gethostbyaddr(ipAddress) print("Host Name for the IP address {} is {}".format(ipAddress, hostName)) |
Output:
Host Name for the IP address 192.0.43.8 is ('43-8.any.icann.org', ['8.43.0.192.in-addr.arpa'], ['192.0.43.8']) |