How to use icanhazip.com icanhaztrace.com and icanhazptr.com with curl

By | 2013/06/17

Major Hayden has created the epic site icanhazip.com which will show your current IP address. There are a few more additions to know about as well. Here is the scoop!


Show your IP address:

http://icanhazip.com

By default, this may show either an IPv4 address or if on an IPv6 enabled network will show your IPv6 address. You can force viewing either IPv4 or IPv6 by using the following URLs:

http://ipv4.icanhazip.com
http://ipv6.icanhazip.com


Perform a traceroute:

http://icanhaztrace.com

Force IPv4 or IPv6 traceroute:

http://ipv4.icanhaztrace.com
http://ipv6.icanhaztrace.com


Show your Reverse DNS record (PTR):

http://icanhazptr.com

Show IPv4 or IPv6 PTR:

http://ipv4.icanhazptr.com
http://ipv6.icanhazptr.com


Use curl!

Apart from a browser, one can also use curl to interact with these urls as well. Again with no arguments on an IPv6 enabled network this will return IPv6. IPv4 peeps, you get an IPv4 back. Using tack 4 or tack 6 will specify IPv4 or IPv6.

$ curl icanhazip.com
2600:3c01::f03c:91ff:fe96:edba

$ curl -4 icanhazip.com
173.230.156.66

$ curl -6 icanhazip.com
2600:3c01::f03c:91ff:fe96:edba
$ curl icanhazptr.com
stmiller.org

$ curl -4 icanhazptr.com
li166-66.members.linode.com

$ curl -6 icanhazptr.com
stmiller.org
$ curl icanhaztrace.com
traceroute to 2600:3c01::f03c:91ff:fe96:edba (2600:3c01::f03c:91ff:fe96:edba), 30 hops max, 80 byte packets
 2  2606:f200:0:5::1  0.549 ms
 3  2001:470:10:1e::1  52.925 ms
 4  2001:470:0:a1::1  53.167 ms
 5  2001:470:0:242::1  88.780 ms
 6  2001:470:0:258::1  107.188 ms
 7  2001:470:0:24a::2  128.454 ms
 8  2001:470:0:72::1  118.584 ms
 9  2001:470:0:18d::1  125.794 ms
10  2001:470:1:3b8::2  126.059 ms
11  *
12  *


$ curl -4 icanhaztrace.com
traceroute to 173.230.156.66 (173.230.156.66), 30 hops max, 60 byte packets
 2  216.69.252.97  1.306 ms
 3  4.28.35.133  4.509 ms
 4  4.69.132.230  4.480 ms
 5  4.69.137.138  8.992 ms
 6  4.69.151.161  9.092 ms
 7  4.69.145.205  9.149 ms
 8  208.49.136.1  8.987 ms
 9  67.17.107.82  43.005 ms
10  64.209.105.42  49.645 ms
11  184.105.223.249  57.392 ms
12  184.105.222.13  61.483 ms
13  65.49.10.218  54.800 ms
14  *


$ curl -6 icanhaztrace.com
traceroute to 2600:3c01::f03c:91ff:fe96:edba (2600:3c01::f03c:91ff:fe96:edba), 30 hops max, 80 byte packets
 2  2606:f200:0:5::1  0.309 ms
 3  2001:470:10:1e::1  53.656 ms
 4  2001:470:0:a1::1  64.361 ms
 5  2001:470:0:242::1  90.758 ms
 6  2001:470:0:258::1  110.259 ms
 7  2001:470:0:24a::2  118.485 ms
 8  2001:470:0:72::1  121.946 ms
 9  2001:470:0:18d::1  126.323 ms
10  2001:470:1:3b8::2  126.554 ms
11  *