One Liner to Get External IP Address



Was poking around ServerFault this morning and came across a great one-liner command using curl which will tell you the device’s external facing IP address. This probably isn’t anything new but it was something that I just haven’t thought of until now.

curl icanhazip.com

Icanhazip.com is just a simple output of the IP address of the accessor, so it is really clean and simple, just how I like it. It is really easy to set up by yourself if you have a domain not doing anything. In index.php, place:

$ip=@$REMOTE_ADDR;  
echo "$ip";