Whether you are running your own home web server, need to remotely access your machine, or even were just curious, you may have found the need to find your system’s current external IP address. Many people use whatismyip.com to find out this information, but over the past few years I’ve been using an alternative service named icanhazip.com.
The tongue-in-cheek name is easy to remember and gives you your IP address reliably and without ads covering the screen. Someone told me about it a while back and I never knew about the story behind it or who ran it, until now.
Rackspace employee Major Hayden runs icanhazip.com as a service to the general internet community. What is great about the site is that there are no ads, text or other “stuff” along with your IP. This allows you to build the domain into scripts to automatically determine what your public IP address is from any system on the earth.
For example, if you are on a linux system with command-line only access, you could simply type ‘curl icanhazip.com‘ and instantly get the public IP of the system.
The actual code behind displaying this content isn’t difficult. For example if you are implementing it on IPv4 only you could use the code:
<?php echo $_SERVER[“REMOTE_ADDR”] ; ?>
Icanhazip.com has some additional features he recently rolled out. IPv6 is now included on the domain – if you are on an IPv6 system it will look up the AAAA record of the domain and return your IPv6 public internet address. To force one or the other, you can use ipv4.icanhazip.com or ipv6.icanhazip.com.
Either way, it is a great site to remember for that occasion when you need to find out your public IP address.