Advertisement

Get Geolocation info of IP Address in Windows 10

In our previous article, we saw how to get the geolocation info for an IP Address using bash, curl and jq in Linux. Let's see how the same can be done in Windows 10. We can use Bash on Linux or PowerShell for the same purpose.

Advertisеment


Again, we will use the free service "freegeoip.net" as a source of the geolocation info. It provides a public HTTP API to search the geolocation of IP addresses. It uses a database of IP addresses that are associated with cities along with other relevant information like time zone, latitude and longitude. This is very useful.

Get Geolocation info of IP Address in Windows 10 using Bash on Ubuntu

If you have Bash on Linux installed, then you can use it in this case. You need to install the jq console JSON parser. Do it as follows.

    1. Open Bash on Ubuntu. You might need to install it first. See the following article:
      How to enable Ubuntu Bash in Windows 10Tip: you can add Bash on Ubuntu to the Explorer's context menu to open it in any desired folder quickly.
    2. Type the following command:
      sudo apt-get install jq

      The application will be installed:install-jq-in-bash-on-ubuntu

    3. Now, you can use the following command:
      curl http://freegeoip.net/json/119.94.116.145>tmpjson.txt && jq '.' tmpjson.txt && rm tmpjson.txt

      The output:running-the-command-in-windows

It is the same command I used in the native Linux environment, however, there is a glitch. In Windows 10, Bash on Ubuntu has broken support for pipeline output. Due to this issue, you cannot combine multiple tools to work together properly.

So I used a temporary file 'tmpjson.txt' which stores the server response and then gets deleted.

If you are not a user of Bash on Ubuntu, you can use PowerShell instead.

Get Geolocation info of IP Address in Windows 10 using PowerShell

Open a new instance of PowerShell as described here: All ways to open PowerShell in Windows 10

Instead of the curl tool, you can use the cmdlet Invoke-RestMethod. It is specially created to work with REST (Representational State Transfer) services which usually return JSON or XML data.

The syntax is as follows:

Invoke-RestMethod -Method Get -Uri http://freegeoip.net/json/119.94.116.145

The result of the command will be as follows:

with-powershell

You don't even need to apply additional formatting to the command. It is already nicely displayed in the output.

That's it.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisеment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

One thought on “Get Geolocation info of IP Address in Windows 10”

  1. On GNU-Linux operating systems, you just need to install geoip-bin and then, use the command:

    geoiplookup 119.94.116.145

    No need for an external website…

Leave a Reply

Your email address will not be published.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.