Services to return text-only public IP
Posted on April 01, 2014
- and tagged as
- networking
The following sites return the source IP of web requests in plain text with no HTML or other formatting.
Examples
Linux:
curl icanhazip.com
PowerShell
$ip = (New-Object Net.WebClient).DownloadString("http://icanhazip.com")
Python
import urllib2
ip = urllib2.urlopen('http://icanhazip.com').read()
Be aware if there are http/s proxies in place the above may not be a true representation of the external IP address. One somewhat dubious method of avoiding this problem is to specify an ACL on a remote device to deny and log traffic to a specific port, eg TCP 9999, then initiate a connection from the source to the specified port via telnet or netcat. This should avoid the proxy server and provide the true public IP.