• About
  • Editorial policy
  • Contact
  • Privacy
  • Legal
  • Cookie settings
Monday, November 2, 2026
  • Login
PacketNebula
  • Home
  • News
  • Tools
    • Network
    • Security
    • Developer
    • Sysadmin
    • SEO
    • Email & DNS
  • Guides
  • Trackers
    • LLM API pricing
    • Open-weight models
    • Retirements calendar
    • Infrastructure deals
  • About
  • Download
No Result
View All Result
PacketNebula
No Result
View All Result
Home Network

How to show your IP address from the command line

by Stéphane Cardon
3 September 2026
in Network
0
ELECOM WRC-300FEBK Wi-Fi router with WAN and LAN port labels on top, lying next to its power adapter

Image: Syced / Wikimedia Commons, CC0

Share on FacebookShare on Twitter

Someone on the phone asks for your IP, and you blank on which command your OS wants. Windows takes ipconfig; Linux wants ip addr, or just ip a if you're typing fast; on a Mac, ifconfig still does the job, and ipconfig getifaddr en0 does it with less noise. Every one of those prints the local address, the private one your router handed out, usually starting 192.168 or 10. That's the number you need for reaching a machine on the same network or checking which interface is actually up. The public address is a different animal. It lives on your router, your machine genuinely has no idea what it is, so we ask an outside service with a one-line curl. Below, the command for each OS, plus how to read past the clutter and why the two addresses never match.

The short answer

Local address: ipconfig on Windows, ip addr (or ip a) on Linux, ifconfig on macOS. The public one, what the internet actually sees, takes curl ifconfig.me on any of them.

ipconfigWindows local IP
ip addrLinux local IP
curl ifconfig.meyour public IP
Answer card showing ipconfig, ip addr and ifconfig for the local IP, and curl ifconfig.me for the public IP.
One command per OS for the local IP, one curl for the public one.

Windows, Linux and macOS

ipconfig dumps every adapter it knows about. On a laptop with a VPN and WSL installed, that’s a screenful. Scan for IPv4 Address under whichever adapter is actually connected, normally Wi-Fi or Ethernet, and skip anything that says media disconnected.

Windows
ipconfig

On Linux it’s ip addr, or ip a if you’re typing fast. The full output is chatty. We go straight to ip -br addr most days: one tidy line per interface with its address and state, done. ifconfig still works on plenty of boxes, but the distros stopped pointing you at it a while ago.

Linux
ip -br addr

macOS still ships ifconfig, but there’s a shortcut that prints only the address of your main interface. Nothing to parse:

macOS
ipconfig getifaddr en0
Terminal showing ip -br addr listing interfaces with their addresses, then curl ifconfig.me returning the public IP.
Local addresses per interface, then the single public address from curl.

The public IP is somewhere else

Everything above is private. The address the internet actually sees belongs to your router, and your machine genuinely doesn’t know it. So we ask someone outside to tell us:

Linux
curl ifconfig.me

For the full picture (public IP plus what your browser reveals), the What Is My IP tool shows it all in one place, and IP geolocation tells you where any address sits.

Two details that turn a confusing answer into an obvious one. A machine on a VPN has more than one address, and the VPN interface will usually be listed first, so the address you want depends on which network you mean. Read the interface name rather than grabbing the first line.

And hostname -I on Linux is the quick one, but it prints every address on every interface separated by spaces, including Docker bridges. When you want one clean answer for the main interface, ask for it specifically.

Linux
ip -4 -brief addr show scope global

There’s a reason this confuses people. The address your machine knows about usually isn’t the one the internet sees, and if there’s a router between you and the world, which there nearly always is, they’re two genuinely different things. Work out which one the question is about before you go looking.

Frequently asked questions

What’s the difference between my local IP and my public IP?

They're almost never the same number. The local IP comes from your router and only means something on your own network; it usually starts 192.168, 10. or 172.16 to 31. The public IP belongs to the router itself, and that's what websites and remote servers actually see. A whole house of devices shares that one public IP.

My ipconfig output lists several adapters. Which one is mine?

Find the one that's actually connected and shows an IPv4 address: usually "Wireless LAN adapter Wi-Fi" on a laptop or "Ethernet adapter" on a desktop. Anything that says media disconnected can be skipped, and so can the virtual adapters VPNs, VirtualBox or WSL leave behind (unless one of those is what you're after).

How do I get just the public IP without a website?

Ask an echo service with curl. "curl ifconfig.me" or "curl -4 icanhazip.com" prints your public IPv4 and nothing else. Works the same on Windows, macOS and Linux as long as curl is installed, and it ships by default on all three now.

ip addr is a lot of output. How do I trim it?

"ip -4 addr" drops the IPv6 noise, and "ip -br addr" gives you one brief line per interface, which is what we reach for first. Want a single interface? Name it: "ip addr show eth0". On older systems ifconfig still works, but it's not the tool Linux points you at anymore.

Tags: cliguidelinuxnetworkwindows
ShareTweet
Previous Post

How to change file permissions with chmod

Next Post

How to do a DNS lookup from the command line

Stéphane Cardon

Stéphane Cardon

Network cybersecurity engineer: architecture, LAN and WLAN, system administration. He runs PacketNebula, where he publishes the tools and answers he wanted for his own work.

Next Post
Blue, grey, green, red and yellow Ethernet patch cables plugged into the ports of a rack-mounted network switch

How to do a DNS lookup from the command line

Free tools

  • IPv4 subnet calculator
  • DNS lookup
  • SSL certificate checker
  • HTTP headers checker
  • SPF, DKIM and DMARC checker
  • JWT decoder
  • Cron expression builder
  • Chmod calculator
  • Password generator

All 24 tools →

Guides to keep handy

  • Flush the DNS cache on Windows
  • Kill the process using a port
  • Generate an SSH key
  • Secure a new Ubuntu VPS
  • Find files on Linux
  • Extract and create tar.gz

More guides →

Who writes this

Stéphane Cardon, network cybersecurity engineer. Architecture, LAN and WLAN, system administration. PacketNebula holds the tools and answers he wanted for his own work.

About this site →

  • About
  • Editorial policy
  • Contact
  • Privacy
  • Legal
  • Cookie settings

Copyright © 2026 Stephane Cardon.

No Result
View All Result
  • Home
  • News
  • Tools
    • Network
    • Security
    • Developer
    • Sysadmin
    • SEO
    • Email & DNS
  • Guides
  • Trackers
    • LLM API pricing
    • Open-weight models
    • Retirements calendar
    • Infrastructure deals
  • About
  • Download

Copyright © 2026 Stephane Cardon.

Cookies, your call

We use Google Analytics to see which pages get read. Once our AdSense application is approved, articles and guides will carry Google ads. Nothing runs until you say yes, and nothing runs on the tool pages. Details