What is My IP Address? How Do I Get My External IP Address in Mac OS X?

Dec 8, 2009 - 13 Comments

Terminal in OS X

One of the quickest ways to get your external IP address in Mac OS X or unix is by launching the Terminal and typing one of the following commands with curl. To be perfectly clear here, we’re looking for the external public IP address of the hardware in use, this is what broadcasts to the world, this is not the same as a LAN IP or local IP, which is usually not public.

To get started open the command line and choose one of the syntax approaches below to retrieve an external IP.

Use curl with ipecho.net to get the public IP address:

curl ipecho.net/plain ; echo

Using ifconfig and curl to get the external IP address of a computer:

curl ifconfig.me

This will report back your IP address by pulling the result from one of the two web services, there are actually quite a few of these services out there so you can try curl with many of them to retrieve the public IP addy.

Alternatively, you could view those type of sites in your web browser and also get your external IP address, but that’s not as quick as using Terminal for many users.

And yes, this works in all versions of OS X on all Macs, and all versions of Linux too. Technically you can visit those above URL’s on any web browser rather than running through curl and you’ll also get their external IP addresses too.

.

Related articles:

Posted by: William Pearson in Command Line, Mac OS

13 Comments

» Comments RSS Feed

  1. Kcidkcus says:

    Just type ‘curl ifconfig.me’ in the terminal.

  2. blameitonthesatellite says:

    This doesn’t seem to work anymore, but

    curl bot.whatismyipaddress.com

    Does.

  3. fjvn says:

    nice info

  4. […] URL bar and type: vnc:// Hit Return and Screen Sharing will launch immediately. If you specified an IP address it will open to that host immediately, otherwise a window will pop up asking you for the VNC Host […]

  5. tejji says:

    and the simple way is here – what is my ip address

  6. Carney says:

    I must say i started loving your blog, so here you got my first comment. i”ll keep bugging you. hope you won’t mind

  7. Adi says:

    or just use whatsmyip.net

  8. Imulus says:

    You could also visit a browser support website such as Support Details (http://supportdetails.com). You can even send your system details to someone else directly within the interface.

  9. marc says:

    feh… it is not reporting *your* ip address, it is reporting the address used to access the site which may be that of a proxy, a router, or some other NAT device. Depending upon your network setup it could be the address of some device at your isp.

    If you want to see what addresses are actually in use by your machine and have a terminal window open use this pipeline:

    ifconfig | grep inet

    which will get you both ip (inet) and ipv6 (inet6) addresses that are in use by your machine. I have two interfaces in use on my machine and use inet6 in addition to inet. My addresses are:

    inet6 ::1 prefixlen 128
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
    inet 127.0.0.1 netmask 0xff000000
    inet6 fe80::21e:c2ff:fe15:f0f6%en0 prefixlen 64 scopeid 0x4
    inet6 2001:5a8:4:910:21e:c2ff:fe15:f0f6 prefixlen 64 autoconf
    inet 208.201.244.209 netmask 0xffffff00 broadcast 208.201.244.255
    inet6 fe80::21e:c2ff:fea3:2733%en1 prefixlen 64 scopeid 0x6
    inet 192.168.168.1 netmask 0xffffff00 broadcast 192.168.168.255
    inet6 2001:5a8:4:911:21e:c2ff:fea3:2733 prefixlen 64 autoconf

    ::1 and 127.0.0.1 are loopback addresses used by all machines.
    fe80:… are internal ipv6 addresses

    • Joshua says:

      Yes and no. Take a typical home or small office set up. You have a router doing NAT with a single public IP. In most instances this is the IP which will be reported by whatismyip.org. Yes, if you are using a proxy, or have some other complexities, the IP reported might not be the Public IP of your router.

      If you run ifconfig on a device which is on a NATted LAN (the most common home, small office set up), then you will ONLY get your LAN IPs. Which probably not what you want.

      So, yeah, it might not give you the address you need, but ifconfig is even less likely to give you that info in most circumstances.

    • Craig says:

      You’re missing the point. You need to know what the IP address that the outside world sees you as for a great number of things, including opening hole in firewalls on client systems to allow remote access, just as a quick example.

  10. Matt says:

    Ha… It returned this result:

    Banned

    You have been banned from this page.
    We’ve put measures in place to keep people from hitting our site at an unreasonable rate.
    We ask that you only hit our site once per every 5 minutes to get your IP address.
    Our system must’ve detected overuse by you and therefore banned you.
    Are you running an automated script to get your IP?
    Once we figure out what caused the ban and get that fixed, we’ll unban you.
    Send questions to banned2 at whatismyip dot com.

    Please set your code to scrape your IP from http://www.whatismyip.com/automation/n09230945.asp

  11. Dale says:

    If you have the luxury of installing on the machine you are using, try the IP Widget. http://cip.physik.uni-bonn.de/~maahn/ip.html

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