HOW TO

How Do You Find a Computer’s Geographic Location Using the Command Line?

How Do You Find a Computer’s Geographic Location Using the Command Line?


how-do-you-find-a-computers-ip-address-location-using-the-command-line-00
  • Facebook
  • Google+
  • Twitter
  • Pinterest

There are many ways to learn the location of a computer from its IP address, but how do you go about it if you decide to use the command line to find the information? Today’s SuperUser Q&A post has some helpful suggestions to help a reader find the information he wants.

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

Screenshot courtesy of Paul Fenwick (Flickr).

The Question

SuperUser reader AlikElzin-kilaka wants to know how to find a computer’s IP address location using the command line:

How do I find a computer’s internet (IP address) location using the command line? Would I use curl or wget, for example?

How do you find a computer’s IP address location using the command line?

The Answer

SuperUser contributors AlikElzin-kilaka and Ben N have the answer for us. First up, AlikElzin-kilaka:

There is a service (IPInfo) that can provide the results. You can invoke it using curl, for example:

Result:

how-do-you-find-a-computers-ip-address-location-using-the-command-line-01
  • Facebook
  • Google+
  • Twitter
  • Pinterest

A specific IP’s info can also be requested:

  • curl ipinfo.io/216.58.194.46

Result:

how-do-you-find-a-computers-ip-address-location-using-the-command-line-02
  • Facebook
  • Google+
  • Twitter
  • Pinterest

Source: How to look up the geographic location of an IP address from the command line

Followed by the answer from Ben N:

Since the question does not specify an operating system, this is how to get that same information with PowerShell’s curl (actually an alias of Invoke-WebRequest):

Which produces a JSON string. To get the object that the JSON represents, use ConvertFrom-Json:

  • curl ipinfo.io | ConvertFrom-Json

Since that is a PowerShell object, you can easily get specific fields from it. For example, this command gets just the external IP address as a string:

  • (curl ipinfo.io | ConvertFrom-Json).ip

Note that the geographical information from this service is not super accurate, but it did locate me within 20 miles or so of my actual location and the ISP information seems to be reliable.


Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

Akemi Iwaya (Asian Angel) is our very own Firefox Fangirl who enjoys working with multiple browsers and loves ‘old school’ role-playing games. Visit her on Twitter and Google+.



Source link

Click to add a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

More in HOW TO

Skype Is Awful for Text Chat. Use Telegram Instead

Sharrit!May 7, 2022

Do I Need an Amazon Echo to Use Alexa?

Sharrit!May 7, 2022

How to Use the Nest Thermostat to Cool Your House Based on Humidity

Sharrit!May 6, 2022

How to View Your Nest Thermostat’s Usage History

Sharrit!May 6, 2022

How Smart or Efficient Could a Workplace Office Network Be?

Sharrit!May 5, 2022

How to Enable One-Handed Mode in Android’s Google Keyboard

Sharrit!May 5, 2022

What to Do If You Can’t Receive Text Messages From iPhone Users

Sharrit!May 4, 2022

How to Organize Your Email with Smart Mailboxes in Apple Mail

Sharrit!May 4, 2022

Geek Trivia: Despite The Common Belief, The Word Sushi Does Not Refer To Raw Fish But?

Sharrit!May 4, 2022

Sharrit.Net Featuring the best top 10 lists, viral news, &; trending video from across the web. Read, watch & share the hottest content online, posted daily at Sharrit.Net

Copyright © 2016 Sharrit.Net MEDIA

Pin It on Pinterest