The macOS way to find your IP address from the terminal isn’t the Linux ip addr or hostname -I — neither of those exists here. It’s ipconfig getifaddr, with one wrinkle: you have to point it at the right network interface. Here’s the reliable command for your local IP, how to tell which interface is which, and how to get your public IP too. Checked on macOS 26.5.2.
Your local IP address
The command is ipconfig getifaddr followed by an interface name. Wi-Fi is usually en0:
$ ipconfig getifaddr en0
192.168.1.42
That’s your Mac’s address on the local network (yours will differ). The catch is that the interface name isn’t guaranteed — plugging in Ethernet or a dock can move it to en1 or beyond, and getifaddr prints nothing for an interface that isn’t carrying an address. The reliable version asks the routing table which interface is actually handling traffic, then reads that one:
$ ipconfig getifaddr "$(route get default | awk '/interface:/{print $2}')"
192.168.1.42
That works whether you’re on Wi-Fi or Ethernet, with nothing to guess. Worth saving as an alias.
Which interface is which
If you want to see which enX is Wi-Fi and which is Ethernet by name, list the hardware ports:
networksetup -listallhardwareports
Each block pairs a port name — Wi-Fi, Ethernet — with its device, like en0 or en1. For the full detail on one interface (address, netmask, status), ifconfig en0 shows everything, and ifconfig en0 | grep 'inet ' narrows it to just the IPv4 line.
Your public IP address
Everything above is a private address on your own network. Your public IP — the one the wider internet sees, assigned to your router — has to come from an outside service, so you ask one over curl:
$ curl -s https://api.ipify.org
203.0.113.7
curl ifconfig.me does the same thing. Both report the address your traffic leaves home from, which is the one you’d give someone for a remote connection or check against a VPN.
Linux habits that don’t work
If you came from Linux, two reflexes fail on macOS. There’s no ip command — macOS doesn’t ship iproute2 — and BSD hostname has no -I:
$ ip addr
zsh: command not found: ip
$ hostname -I
hostname: illegal option -- I
The first is just a “command not found” for a tool that was never there; ipconfig getifaddr is the macOS equivalent to reach for instead. So: ipconfig getifaddr with the route get default one-liner for your local IP, networksetup -listallhardwareports to name the interfaces, and curl for the public address. All checked on macOS 26.5.2.