Apple - How to get the geolocation of an IP address in Terminal?

You can do this without having to install any additional apps or software. Just use the command curl and the free geo ip website

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


You will get your results in an XML format:

    <CountryName>United States</CountryName>

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


Other Formats... also supports CSV, JSON and JSONP

CSV: curl,US,United States,CA,California,Cupertino,95014,America/Los_Angeles,37.30,-122.09,807

JSON: curl

{"ip":"","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: