Find your IP Address on a Mac

Nov 21, 2010 - 24 Comments

Finder Knowing your Mac’s IP address is important for setting up a network or sharing files, here’s two different ways to find your IP address in Mac OS X; an easy way through the GUI and a more technical approach with the command line. These methods will be the same whether you are connected via ethernet or wireless.


This works the same in all versions of Mac OS X on all Macs.

How to Find the IP Address on a Mac

You can find any Macs IP, or your IP address from the Mac System Preferences Network configuration screen:

  1. From the Apple menu pull down “System Preferences”
  2. Click on the “Network” preference pane
  3. Your IP address will be visible to the right, as indicated in the screenshot below

ip address mac

Your IP address is the number listed, in the above case it is 192.168.0.100

Now we’ll cover the more technical approaches to getting your IP address using the Mac OS X command line:

Find your IP Address via the Mac OS X Terminal

This is how to find the IP address of your Mac through the Terminal, this is often the quickest way for those that are more technically inclined.

  • Launch the Terminal located in /Applications/Utilities/
  • Type the following command:

ifconfig |grep inet

  • You will see something that looks like this:

inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
inet6 fe80::fa1e:dfff:feea:d544%en1 prefixlen 64 scopeid 0x5
inet 192.168.0.100 netmask 0xffffff00 broadcast 192.168.0.255

  • Your IP address is usually next to the last entry of ‘inet’ and in this case is 192.168.0.100, an IP address is always in the format of x.x.x.x but it will never be 127.0.0.1 because that is your machines loopback address. Because you can always ignore 127.0.0.1, this guarantees that your IP address will be the other IP between ‘inet’ and ‘netmask’

The other command line option is to use: ipconfig getifaddr en1 which reports back only your en1 (usually wireless) IP address. You can change this to en0 for wired/ethernet too. I have heard ipconfig is not supported in all versions of Mac OS X so I did not recommend this as the first choice. However, using ipconfig you can also set your IP address from the command line.

Find your External Public IP Address in Mac OS X

Your external IP address is what is broadcast to the world rather than your local network (behind a wireless router, for instance).

You can find your external IP address easily by going to a website like Google and typing “what is my IP address” or by going to websites like “whatismyipaddress.com” and checking there.

This is easiest to find through a Terminal command a well:

curl ipecho.net/plain ; echo

or

curl whatismyip.org

This will instantly report back your external IP address. We covered this command when finding your external IP address in the past.

.

Related articles:

Posted by: David Mendez in Mac OS, Tips & Tricks

24 Comments

» Comments RSS Feed

  1. Burcuk says:

    Thank you, very helpful!

  2. vamy says:

    Very well written.

    Thank You!

  3. Steve F says:

    I liked some of the alternatives since ifconfig en0 only gives me ipv6 address. So I though I’d add this for getting the LAN ipv4 address.

    “`bash

    echo “function ipv4() { ping -n -c 1 `hostname` | head -n 1 | awk ‘{print $3}’ | sed ‘s/[():]//g’; }; alias ip=ipv4;” >> ~/.bash_profile; source ~/.bash_profile;

    “`

  4. CKNY says:

    Very good overview and explanation! I did not have any issues with the description provided. All of them worked and revealed the expected results! Thanks for that article.

  5. Calum says:

    To find the local IP address, which is useful for many reasons, I would use hostname -i … but this isn’t supported on the mac, so instead I use the following script (do not include the EOF)

    :
    ping -n -c 1 `hostname` 2>&1 | grep “^[0-9]* bytes from” | sed ‘s/^[0-9]* bytes from \([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\):.*$/\1/’
    EOF

    make it executable like this:
    $ chmod a+x get_host_ip
    (or whatever name you choose)
    run it from the command line like this:
    $ ./get_host_ip
    your.ip.address.here

    Or any of the other wonderful methods already posted.

  6. Enkouyami says:

    This works on Linux too.

  7. […] Get the Macs IP address – Go to “System Preferences” and “Network” to retrieve the IP […]

  8. […] troubleshoot devices, and anyone who’s had to dig around in the System Preferences to find Mac IP and MAC addresses on multiple machines, or in Network Settings on a bunch of iPhone, iPad, or Apple […]

  9. […] a note of the Macs IP address, that is what you will be connecting […]

  10. greno says:

    Where’s ‘hostname -i’ like on linux when you need it?

    .

  11. […] that is assigned to each physical network interface on a computer. Different than a computers IP address, MAC addresses are frequently used for network access control and to monitor network connectivity, […]

  12. […] launch a web browser and double-check the external IP address to confirm with a website like whatismyip.org or by running the following at the command […]

  13. […] a routers IP address is by going through System Preferences. This is much the same way that you get your Macs IP address, but the router IP is a few steps further in preference […]

  14. […] clarify here, the routers IP and your own IP address are different things. Being the start of a network, the access point typically holds the very first […]

  15. […] SMB enabled, we now can connect from the Windows PC to the Mac. If you already know the Macs IP address you can skip this first part of this and go directly to the Windows PC to access the shared users […]

  16. […] can always find your IP address in Mac OS X through System Preferences, using the command line, or accessing a web site like […]

  17. Marc says:

    Since ianf is so concerned about misinformation,

    it should be noted that the address 192.168.0.0 is NOT ALWAYS the main node. It is certainly possible to be limited to fewer than 254 other addresses, or far, far more addresses. And IP addresses are not necessarily assigned “in turn” (though they usually are).

  18. ianf says:

    Gosh, why are you misinforming largely clueless people?

    This in NOT one’s Mac’s IP address (on the net), it’s a *LOCAL* address within the local area network, e.g. when you have a wireless router connected to your cable/DSL-modem. The address 192.168.0.0 is always the main node, usually the one built into the router, and you can have up to 254 other units connected to the same net (=capacity of the last component in the address; they are assigned in turn).

    Your only true IP address (which belongs to the LAN, which then shares it among all the connected units with the various LOCAL IP# assigned to them) is the one returned by (e.g.) http://www.whatismyip.com/

    Try this, you’ll immediately see the difference. And quit serving misinformation on the net, there’s enough of such there already.

    • Chowder Powder says:

      You don’t know the difference between a local and external IP? Obviously the IP on a LAN is different.

    • David says:

      @ianf

      The purpose of the article is to inform Mac users how to find their IP addresses. You often need to know what a local IP is for local file and print sharing (particularly true with a Windows & Mac OS X network), but the article covers finding both local and external IP addresses.

      Perhaps you missed the last part of the article which discusses using curl to find an external IP address.

      If you have any suggestions on clarifying the article, feel free to submit them to: osxdailycom@gmail.com

    • Joaquin Palacios says:

      Thanks to you and not the 1st person who posted I could configure my internet.

    • Claudia says:

      I think that the problem is that ianf isn’t a native speaker of English. I certainly understood the intent of the article, though some of it is still not clearly written after two plus years of scrutiny.

  19. Johannes says:

    Or simply use ifconfig en1 in the terminal

  20. Alberto says:

    I simply use some site like: whatismyipaddress.com

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site