MainspringGuides › Find IP address
macOS Guide

Find Your IP Address From Terminal on Mac

Updated July 2026 · 3 min read

"What's your IP?" has two correct answers: the local address your router gave your Mac, and the public address the internet sees. Terminal gets both faster than any settings pane — one command each. Everything here is read-only; you're looking up facts, not changing anything.

Your local IP in one command

# the address your router assigned (Wi-Fi on most Macs)
ipconfig getifaddr en0

That prints something like 192.168.1.42 — the address other devices on your network use to reach this Mac, for screen sharing, file sharing, or a dev server you're running. en0 is the Wi-Fi interface on almost every Mac laptop; on a desktop wired first, Ethernet may own en0. If the command prints nothing, that interface simply has no address — try en1, or get the definitive interface map:

# which device name belongs to which port
networksetup -listallhardwareports

The old workhorse ifconfig still works when you want everything at once: ifconfig | grep "inet " lists the IPv4 address of every active interface (ignore 127.0.0.1 — that's the Mac talking to itself).

Your public IP

Your Mac doesn't know its public address — your router hides it behind NAT — so the trick is asking an outside service to read it back to you:

# ask an echo service what address you appear from
curl ifconfig.me

# an alternative, HTTPS and script-friendly
curl -s https://api.ipify.org

This is the address websites see, the one geo-restrictions act on, and the one you'd give someone connecting to your network from outside. On a VPN, expect it to be the VPN provider's address — that's the VPN doing its job. Note these echo services are third parties; any of them learns your IP when you ask (which is unavoidable — that's the mechanism).

Local vs public, in one paragraph

Your router owns one public address facing the internet and hands out private addresses (192.168.x.x, 10.x.x.x, or 172.16–31.x.x) to every device behind it. Local addresses only mean something inside your network — give a friend across town your 192.168.1.42 and it points at their router's territory, not yours. Rule of thumb: sharing between devices in the same building uses the local address; anything crossing the internet involves the public one.

Bonus: find your router while you're here

# the gateway your traffic leaves through
route -n get default

The gateway line in the output is your router's address — the thing to put in a browser when you need the router's admin page, and the address to ping first when the internet "is down" (if the router answers but websites don't, the problem is upstream of you). A quicker filter: route -n get default | grep gateway.

IPv6, and the Settings route

# your IPv6 addresses, if the network provides them
ifconfig en0 | grep inet6

# your public IPv6 (errors if you have no IPv6 route)
curl -6 -s https://api64.ipify.org

Many home networks now hand out both address families: the fe80:: entries are link-local housekeeping you can ignore, while addresses starting with 2 or 3 are globally routable. And for completeness, the pointing-and-clicking route: System Settings → Wi-Fi, click Details… next to the connected network, and the TCP/IP tab shows the local address and router together. Terminal remains faster the second time you need it.

Look it up once, tune it forever

Terminal answers questions; Mainspring changes answers. 90+ hidden macOS settings as labelled, reversible toggles — network niceties included.

Try Mainspring free →

Signed & notarized by Apple · 1-day free trial · $29 once

When the answer looks wrong

A local address starting 169.254 means your Mac gave up waiting for the router and invented an address — no DHCP reply. That's a connection problem, not a lookup problem; our guide to Wi-Fi connected but no internet picks it up from there.