Fork me on GitHub

ident.me: free public IP address API

We expose your IP address on the Internet.

This means NAT & proxies affect the results, and the answer differs from eg ipconfig, ifconfig, ip addr.

Feel free to use this service for anything, from anywhere. We handle billions of requests per month and 10× load tests. If you expect to send more than 5,000 requests per second, please E-mail first.

Apps

Libraries

None so far; please share here if you build one.

APIs

You can find your public IP address at ident.me over HTTP(S), DNS, SSH, telnet(s), and STUN.

To specify IPv4 or IPv6, prefix with 4. or 6..

Over HTTP(S), access /json to get JSON instead of plain text, which includes geolocation information. Every value is a string and missing values can be empty strings (sorry), null, or undefined.

Over DNS, request any name. Over SSH, do not pass a command.

To find the public IP of your DNS servers, resolve ns.ident.me, ns4.ident.me, or ns6.ident.me.

You can also get a unique 63-bit identifier represented in hexadecimal over HTTP(S) at ident.me/n. Falling back to tnedi.me is safe.

Redundancy & alternatives

If you need reliable lookups, please build redundancy.

tnedi.me mirrors this service from another datacenter and gets maintained first.

Alternatives can be found in go-external-ip, gip (rust), WooCommerce.

Examples

Display the public IP (IPv4 or IPv6), in shell:

IP=$(
  (command -v dig &> /dev/null &&
    (dig +short @ident.me ||
     dig +short @tnedi.me)) ||
  (command -v nc &> /dev/null &&
    (nc ident.me 23 < /dev/null ||
     nc tnedi.me 23 < /dev/null)) ||
  (command -v curl &> /dev/null &&
    (curl -sf ident.me ||
     curl -sf tnedi.me)) ||
  (command -v wget &> /dev/null &&
    (wget -qO- ident.me ||
     wget -qO- tnedi.me)) ||
  (command -v openssl &> /dev/null &&
    (openssl s_client -quiet -connect ident.me:992 2> /dev/null ||
     openssl s_client -quiet -connect tnedi.me:992 2> /dev/null)) ||
  (command -v ssh &> /dev/null &&
    (ssh -qo StrictHostKeyChecking=accept-new ident.me ||
     ssh -qo StrictHostKeyChecking=accept-new tnedi.me)) ||
  (echo "Could not find public IP through api.ident.me" >&2
   exit 42)
)
echo "Found public IP $IP"

Fetch and display the public IPv4 address, in PowerShell:

$IP = try { (Invoke-WebRequest -Uri 4.ident.me).Content }
  catch { (Invoke-WebRequest -Uri 4.tnedi.me).Content }
Write-Output "Found public IPv4 $IP"

Securely fetch and display the public IPv6 address, in Python:

from urllib.request import urlopen
def public_ipv6():
  try:
    with urlopen('https://6.ident.me') as response:
      return response.read().decode('ascii')
  except:
    with urlopen('https://6.tnedi.me') as response:
      return response.read().decode('ascii')
print("Found public IPv6", public_ipv6())

Confirm the configured timezone matches geographically, in JavaScript:

async function ident() {
  try { return await(await fetch('//ident.me/json')).json(); }
  catch { return await(await fetch('//tnedi.me/json')).json(); }
}

Intl.DateTimeFormat().resolvedOptions().timeZone ===
  (await ident()).tz

ipify and seeIP have plenty of examples to draw inspiration from.

Monitoring

Check our status with uptimerobot.com.

Durability

This service has been around since late 2012. If you'd like to increase the bus factor (one) and help keep it around, please reach out!

Privacy & logging

Logs are occasionally kept locally for public operational analytics and interactive troubleshooting, alongside traffic analysis tools.

They are not used or shared in any other way for any other purpose, unless legally required to do so.

Performance

If the response time of this service surprises you, it's probably because we're located in Europe and most alternatives are in North America. The service time itself is usually negligible, you're mostly observing network latency between your client and Germany.

Implementation

In DNS, our root and any. have both A and AAAA records, 4. only has an A record, 6. only has an AAAA record; ns, ns4, and ns6 have corresponding NS records.

All records point to a cheap VPS in Nuremberg, Germany running Ubuntu Jammy with:

  1. Some sysctls for scalability;
  2. TLS certificates maintained by certbot on a timer;
  3. GeoLite2 City & GeoLite2 ASN maintained by geoupdate on a timer;
  4. nginx with a short configuration;
  5. OpenSSH configured with Port 2222 in /etc/ssh/sshd_config;
  6. identssh;
  7. identdns;
  8. identtelnet;
  9. identhttp;
  10. stuntman;
  11. No crash reporting.

Supporting the service

I welcome sponsorships on GitHub.

Remarks, requests, suggestions? Contact Pierre Carrier.