How to get the geolocation of an IP address in Terminal? Is it possible to get the geolocation of an IP address in Terminal?

Not sure what the numbers in an IP address mean, but there must be some logic behind it, so lookup can't be that hard.
You can do this without having to install any additional apps or software.  Just use the command curl and the free geo ip website http://freegeoip.app.

Execute the following command in Terminal (I am using Apple's IP for this example):

curl https://freegeoip.app/xml/17.178.96.59

You will get your results in an XML format:

&lt;Response&gt;
    &lt;IP&gt;17.178.96.59&lt;/IP&gt;
    &lt;CountryCode&gt;US&lt;/CountryCode&gt;
    &lt;CountryName&gt;United States&lt;/CountryName&gt;
    &lt;RegionCode&gt;CA&lt;/RegionCode&gt;
    &lt;RegionName&gt;California&lt;/RegionName&gt;
    &lt;City&gt;Cupertino&lt;/City&gt;
    &lt;ZipCode&gt;95014&lt;/ZipCode&gt;
    &lt;TimeZone&gt;America/Los_Angeles&lt;/TimeZone&gt;
    &lt;Latitude&gt;37.3042&lt;/Latitude&gt;
    &lt;Longitude&gt;-122.0946&lt;/Longitude&gt;
    &lt;MetroCode&gt;807&lt;/MetroCode&gt;
&lt;/Response&gt;


You can even issue the same command using the domain name instead of the IP:

curl https://freegeoip.app/xml/apple.com

Other Formats...

freegeoip.app also supports CSV, JSON and JSONP

CSV:
curl https://freegeoip.app/csv/apple.com 

17.178.96.59,US,United States,CA,California,Cupertino,95014,America/Los_Angeles,37.30,-122.09,807


JSON:  curl https://freegeoip.app/json/apple.com

{"ip":"17.178.96.59","country_code":"US","country_name":"United States","region_code":"CA","region_name":"California","city":"Cupertino","zip_code":"95014","time_zone":"America/Los_Angeles","latitude":37.3042,"longitude":-122.0946,"metro_code":807}


To check your own ip...

Just omit the ip or domain:

curl https://freegeoip.app/xml/