Services to return text-only public IP

The following sites return the source IP of web requests in plain text with no HTML or other formatting.

icanhazip.com
ifconfig.me/ip

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.


If you enjoyed this post consider sharing it on , , , or , and .