Wednesday, 5 September 2012

Get IP of an External Host

For a host with a host name, the following script can return its IP.

Source Code


import socket
hostname = 'maps.google.com'
addr = socket.gethostbyname(hostname)
print 'The address of', hostname, 'is', addr

Output


# python getIP.py
The address of maps.google.com is 74.125.128.138

No comments:

Post a Comment