Friday, 23 September 2016

Python get server external IP address

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("gmail.com",80))
print(s.getsockname()[0])
s.close()

No comments:

Post a Comment

Search