My IP address

- To view your (visitor's) real IP address information, click here
macOS, Linux, OpenWRT, Raspberry Pi, BSD
curl ipin.io

Standard curl command works on most Unix-like systems. For JSON output:

curl ipin.io/json
Android (Termux)
curl --ipv4 ipin.io

Force IPv4 connection in Termux. Alternative with timeout:

curl --connect-timeout 5 ipin.io
Windows PowerShell
(Invoke-WebRequest -Uri "http://ipin.io").Content

Simplified PowerShell syntax. For JSON response:

(Invoke-WebRequest -Uri "http://ipin.io/json").Content | ConvertFrom-Json
iOS (iSH Terminal)
wget -qO- ipin.io

Quiet mode (-q) with output to stdout (-O-). For Alpine Linux (iSH base):

apk add curl && curl ipin.io
OpenWRT Router
wget -qO- --timeout=10 ipin.io

Recommended for resource-constrained devices. If wget isn't available:

opkg install wget-ssl
Docker Container
curl --max-time 5 ipin.io

For minimal containers without curl:

docker run --rm alpine wget -qO- ipin.io
Browser JavaScript
fetch('https://ipin.io/get_client_ip')
  .then(r => r.ok ? r.json() : Promise.reject('API error'))
  .then(data => console.log('IP:', data.ip))
  .catch(e => console.error('Error:', e))

Basic implementation with error handling. For production use:

  • Add timeout handling using AbortController
  • Consider CORS requirements if making cross-origin requests
  • Cache results to avoid rate limiting

Note:

Browser APIs may return different IPs than server-side checks due to proxies/VPNs. For accurate client IP in web apps, consider server-side detection.

Detailed Introduction to the IP Query Tool

This tool is a comprehensive cross-platform solution for querying public IP addresses, designed specifically for developers and system administrators. It accurately retrieves the public IP address of devices in various complex network environments. Unlike traditional IP query services, this solution is optimized for different operating systems and environments to ensure stable performance in various scenarios.

The tool supports multiple platforms including macOS/Linux terminals, Windows PowerShell, Android Termux terminal, iOS iSH terminal, OpenWRT router systems, and Docker container environments. Each platform provides verified best practice commands, taking into account differences in network stack implementations, default toolchain features, and common configuration limitations.

Specially noteworthy, we also provide a complete browser-side JavaScript implementation, based on the modern fetch API, supporting Promise-based asynchronous calls, making it easy for front-end developers to integrate into web applications. This solution handles cross-origin (CORS) issues and includes robust error handling.

All query interfaces support both IPv4 and IPv6 dual-stack protocols, automatically selecting the optimal query method based on the network environment. The returned results are available in both plain text and JSON formats, with the JSON format providing complete IP-related information such as geolocation, network operator, and other extended data.

Detailed Usage Guide

1. Environment-specific Commands

Depending on the running environment, we recommend using the following optimized commands:

  • Unix-like Systems (macOS/Linux/BSD etc.):
    curl -s ipin.io

    Use the curl tool for simplicity and efficiency, with the -s flag to enable silent mode to avoid unnecessary output. It's recommended to add a timeout parameter: --connect-timeout 3

  • Windows Systems:
    (Invoke-WebRequest -Uri "http://ipin.io" -UseBasicParsing).Content

    Native PowerShell command. For older systems, you can use: (New-Object Net.WebClient).DownloadString("http://ipin.io")

  • Mobile Devices:
    # Android Termux
    curl --ipv4 --silent ipin.io
    
    # iOS iSH
    wget -qO- --no-check-certificate ipin.io

    Android forces IPv4 to avoid dual-stack issues, while iOS skips certificate validation. It's recommended to add retry logic for better reliability.

2. Advanced Usage Tips

  • JSON Format Output:

    Add the /json path to any command URL for structured data:

    curl ipin.io/get_client_ip

    Sample response:

    {"ip": "203.0.113.45"}
  • Network Debugging Tips:

    For complex network environments, we recommend the following parameter combinations:

    curl --retry 2 --connect-timeout 5 --max-time 10 ipin.io

    This command attempts to connect within 5 seconds, retries up to 2 times, and ensures the entire request is completed in 10 seconds.