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 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:

echo "$ip";


Dave Drager

Dave Drager


Sign in or become a free systemBash member to read and leave comments.
Just enter your email below to get an easy log in link.