There's no single command for this, which is the first thing that trips people up. On Windows we type ipconfig. On Linux it's ip addr, or just ip a. On a Mac, ifconfig still works, or the tidier ipconfig getifaddr en0. All of them hand you the local address, the private one your router assigned, usually starting 192.168 or 10. That's the one you want for reaching a machine on the same network or checking which interface is actually up. The public address, the one the rest of the internet sees, lives on your router instead, so we ask an outside service for it with a one-line curl. Below: the command per OS, how to read past the clutter to the address that matters, and why the two differ.
The short answer
Local address: ipconfig on Windows, ip addr (or ip a) on Linux,
ifconfig on macOS. Public address, the one the internet sees:
curl ifconfig.me on any of them.
Windows
ipconfig dumps every adapter it knows about, which on a laptop with a VPN and
WSL installed can be a screenful. The line you actually want is IPv4 Address,
under whichever adapter is connected, normally Wi-Fi or Ethernet. Skip the ones
that say media disconnected.
ipconfig Linux
On Linux it’s ip addr, or ip a if you’re typing fast. The full output is
chatty, so we usually go straight to ip -br addr, which prints one tidy line per
interface with its address and state. ifconfig still works on plenty of boxes,
but it’s no longer the tool the distros point you at.
ip -br addr macOS
macOS still uses ifconfig, but there is a shortcut that prints only the
address of your main interface, with no parsing:
ipconfig getifaddr en0
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:
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.
Frequently asked questions
What is the difference between my local IP and my public IP?
The local IP is private, assigned by 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 your router and is what websites and remote servers actually see. Many devices share one public IP behind a router, so the two are almost always different.
My ipconfig output lists several adapters. Which one is mine?
Look for the adapter that is actually connected and has an IPv4 address: usually "Wireless LAN adapter Wi-Fi" on a laptop or "Ethernet adapter" on a desktop. Ignore the ones that say media disconnected, plus virtual adapters from VPNs, VirtualBox or WSL unless that is what you are after.
How do I get just the public IP without a website?
Ask an echo service over curl: "curl ifconfig.me" or "curl -4 icanhazip.com" prints your public IPv4 and nothing else. It works the same on Windows, macOS and Linux as long as curl is installed, which it is by default on all three now.
ip addr is a lot of output. How do I trim it?
Use "ip -4 addr" to drop IPv6, or "ip -br addr" for a one-line-per-interface brief view. To read a single interface, name it: "ip addr show eth0". On older systems ifconfig still works but is no longer the recommended tool on Linux.