import urllib2 def get_external_ip(): ip = urllib2.urlopen("http://whatismyip.org").read() return ip