Python Code Snippet to Get External IP Address
UPDATE, 2010-05-09: Corrected to return external IP even when on subnet.
The following function returns the current external ip address:
import urllib def get_external_ip(): ip = urllib.urlopen("http://whatismyip.org").read() return ip
feed
It must be wrong.
This function returns Internal IP, not the external one.Post new comment