Simple Way to Check Your Public IP (Windows, Linux, Mac CURL Command)

Page content

If you work with computers you probably need to check your public IP address from time to time.
Maybe you’re setting up remote access or adding your IP to a server firewall.
Or maybe you just want to verify your VPN is actually working.

Most people would just google “what is my IP” or visit some IP checking website.
But I’ve got a much simpler method using curl that I want to share with you guys.

ifconfig.me Website

https://ifconfig.me

This website shows your public IP address as soon as you visit it.
No ads and no cluttered UI.
Just your IP address displayed nice and clean.

Checking public IP address on ifconfig.me website

Just type ifconfig.me in your browser’s address bar and you’re done.
Once I memorized this URL I pretty much stopped using any other IP checking sites.

If you’re a Windows user you’re probably familiar with the ipconfig command.
But for Linux and Mac users ifconfig is the common one.
ifconfig stands for interface configuration and it’s the command used for network settings in Linux/Unix systems.

I’m pretty sure that’s where the ifconfig.me site got its name from.

Using CURL in Terminal

Here’s the thing though.
I prefer checking my IP from the terminal rather than opening a browser.
If you’re a developer or sysadmin you probably have a terminal window open all the time anyway.
Why bother opening a browser when you can just run a quick command?
This is also usefull when you don’t have access to a web browser.

The best part is this works exactly the same on Windows Linux and Mac.

Windows Example

On Windows just open Command Prompt or PowerShell and type the following command.

C:\Users\Andy> curl ifconfig.me
102.81.31.34

Windows 10 and later versions come with curl pre-installed so you can use it right away.

Linux Example

On Linux just open your terminal and type the same thing.

Andy@ubuntu:~$ curl ifconfig.me
102.81.31.34

Most Linux distros have curl installed by default.
If you don’t have it just run sudo apt install curl to install it.

Mac Example

On Mac open the Terminal app and type the same command.

Andy@macbook ~ % curl ifconfig.me
102.81.31.34

macOS comes with curl pre-installed so you’re good to go.

How It Works

Let me give you a quick explanation of how this works.

ifconfig.me is a website that shows visitors their IP address.
curl is a command that lets you access web pages from the terminal.

When you use curl to visit a website it displays the raw HTML code in your terminal.
For example if you type curl google.com you’ll see something like this.

C:\Users\Andy>curl google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

Your web browser interprets this HTML and renders a nice looking page.
But curl just shows you the raw code as is.

The cool thing is ifconfig.me can tell how you’re accessing it.
If you visit with a web browser it shows you an HTML page.
But if you access it with curl it just outputs the IP as plain text.
Pretty thoughtful design for us terminal users.

So when you type curl ifconfig.me you’re basically visiting that website from your terminal and it returns your IP without any HTML junk.

Similar Services

There are a few other services that do the same thing.
You can use these as alternatives if ifconfig.me is down for some reason.

  • curl ifconfig.co
  • curl icanhazip.com
  • curl ipinfo.io/ip

Personally I stick with ifconfig.me becuase it’s easy to remember.

See? Easy.