Find your IP address from the command line

Two different things people mean when they say "my IP address": the local one on your network, and the public one the rest of the internet sees.

Local IP address

ipconfig getifaddr en0

This gives you the IP address of your Wi-Fi connection. If you are on Ethernet, use en1 instead (or check ifconfig to find the right interface).

Public IP address

curl ifconfig.me

This calls an external service that tells you the IP address your router presents to the internet.

Quick reference

CommandWhat it returns
ipconfig getifaddr en0Local IP (Wi-Fi)
ipconfig getifaddr en1Local IP (Ethernet)
curl ifconfig.mePublic IP

Enjoyed this post?

Well, you could share the post with others, follow me with RSS Feeds and/or send me a comment via email.


Tags

Category:

Year: