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.
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
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):
You will get your results in an XML format:
<Response> <IP>126.96.36.199</IP> <CountryCode>US</CountryCode> <CountryName>United States</CountryName> <RegionCode>CA</RegionCode> <RegionName>California</RegionName> <City>Cupertino</City> <ZipCode>95014</ZipCode> <TimeZone>America/Los_Angeles</TimeZone> <Latitude>37.3042</Latitude> <Longitude>-122.0946</Longitude> <MetroCode>807</MetroCode> </Response>
You can even issue the same command using the domain name instead of the IP:
freegeoip.app also supports CSV, JSON and JSONP
To check your own ip...
Just omit the ip or domain: