Every Monday we show you how to do something quick and cool using built-in OS X utilities such as Terminal, Apple’s command line application. These easy hacks can make life better and simpler, and don’t require any knowledge of coding — all you need is a keyboard to type ’em out!
It can occasionally become important to know and understand your public IP address for your Internet connection. Whether you’re running your own server or potentially using SSH to connect remotely, knowing your public IP can be beneficial. Unfortunately, most of the ways to find out your public IP address require visiting arcane websites or calling up your ISP (Internet service provider). Fortunately, there’s an easier way thanks to the Terminal. Continue reading and we’ll show you how to retrieve your public IP address.
There is a service called IPEcho that will figure out your IP address and allow you to display it using a simple Terminal command; and while you could look up your IP address via a website or through Google by typing “What is my IP address?” using this command can provide extra functionality by including it in scripts.
To get the public IP address of your Internet connection, open the Terminal application (located in /Applications/Utilities), and type in the following command:
curl ipecho.net/plain; echo
After doing this, you will notice that the IP address will be printed to the screen. While this is a simplistic use of the command, you could theoretically use it in conjunction with a shell script to add even more functionality, such as automatically reporting an IP address change.
Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow this article’s author on Twitter.