Best Way To Find Public IP Address [using 1 Command Line]

You may wish to find public IP address (a.k.a, The external IP address) for various reasons. For example, you may want to test that your proxy settings are working correctly, to find the location of a proxy server or temporally expose your service to the outside world.

Find Public IP address

Whatever the reason you want to find the public IP address, You can use several sites to accomplish the task.

However, you can easily do a command line with the help of the API from The API is a simple API that allows you to find the public IP, the region, city, country, and the timezone. Moreover, It supports up to 1000 requests per day without signup and has very comparative prices, in the case more calls are needed.

To Find your public IP or external IP is simple. Just invoke the following command:

Find Public IP Address With Command Line
 ~/# curl

Besides of your public IP address, you can find more data about the your Public IP with the json endpoint. This endpoint return json with more data about the public IP address such as city, country, timezone and utc_offset.

Find Public IP Address And Other Data
~/# curl
  "ip": "",
  "city": "London",
  "region": "England",
  "region_code": "ENG",
  "country": "GB",
  "country_name": "United Kingdom",
  "continent_code": "EU",
  "postal": "EC2V",
  "latitude": 51.5142,
  "longitude": -0.0931,
  "timezone": "Europe/London",
  "utc_offset": "+0000",
  "country_calling_code": "+44",
  "currency": "GBP",
  "languages": "en-GB,cy-GB,gd",
  "asn": "AS14061",
  "org": "DigitalOcean, LLC"

You can also find specific field value of the above IP data Find your public IP

Find Public IP Address With Country, City, Region and Timezone
~/# curl
~/# curl
~/# curl
~/# curl
~/# curl
~/# curl

Find Proxy Server Location

The curl -x allows to fetch a page via proxy. We can use it to find the IP data of the proxy server. Suppose you want to find the location of your proxy server my-proxy at port 8085:

Find proxy server location – country,city and timezone
 ~/# curl -x http://my-proxy:8085
 ~/# curl -x http://my-proxy:8085
 ~/# curl -x http://my-proxy:8085
 ~/# curl -x http://my-proxy:8085
 ~/# curl -x http://my-proxy:8085

For IP Address Data For Web Developers

If you web developer you can use the API to display customized content of your website based on the location of the IP. For example, you can display the relevant flag or currency. Another example, you can display relevant locations and events based on the visitor’s country or city.

Suppose you want to find data of the machine (Google Public DNS) :

 ~/# curl
     "ip": "",
     "city": "Mountain View",
     "region": "California",
     "region_code": "CA",
     "country": "US",
     "country_name": "United States",
     "continent_code": "NA",
     "postal": "94035",
     "latitude": 37.386,
     "longitude": -122.0838,
     "timezone": "America/Los_Angeles",
     "utc_offset": "-0800",
     "country_calling_code": "+1",
     "currency": "USD",
     "languages": "en-US,es-US,haw,fr",
     "asn": "AS15169",
     "org": "Google LLC"

Leave a Reply

Your email address will not be published.