Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

IP Geolocation (?) [Resolved]

Not really a programming question but thought maybe some expert can help me out.

I am looking for a way to check my IP geolocation using only internal operating system tools (e.g Terminal/Command Prompt) MacOS/Windows. Is there a way to do it? I know there are several websites that you can just check that but I am not interested in that.

Google was not my friend here unfortunately.

2 Answers

I don't know about this but maybe this thread would help you: http://hints.macworld.com/article.php?story=20100109053441706

Thanks Ethan!! - although the article you linked did not help, it got me thinking of using different search terms and I was able to find a perfect solution for MacOS using the JSON API of ipinfo.io

curl ipinfo.io

Gives the following results:

bash-3.2$ curl ipinfo.io
{
  "ip": "266.266.266.266",
  "hostname": "athedsl-413388.home.otenet.gr",
  "city": "Athens",
  "region": "Attica",
  "country": "GR",
  "org": "AS6799 Ote SA (Hellenic Telecommunications Organisation)"
bash-3.2$ 

Now I need to find something similar from the Windows OS side! :D

Michael Afanasiev That's cool! maybe that would help me for something in the future, If you find something for windows please tag me so I can read it too :P

Ethan Rivas - I am back, and yay! I have a Windows answer as well!

Open PowerShell as admin and write:

curl ipinfo.io | select -ExpandProperty content 

It will output the same result like terminal.

Michael Afanasiev Thanks for the tag, for what are you using this if I can know? :p

You're welcome.

I will mainly use this at my work where we have way too many security polices. Some of our clients from time to time stumble upon an error that their location (by IP) is not valid for that product license. So before taking matters to more drastic solutions and workarounds, I would like to check where that geo block comes from, the ISP or the product license.

Plus, it's always good to know your way around the command-line!