How to Find Your Public IP Address Using Linux Terminal, PowerShell, and CMD
Whether you are configuring firewall whitelists, scripting cloud provisioning pipelines, or diagnosing headless server connectivity, querying your external WAN IP from a terminal is essential. Here is the definitive guide to finding your public IP using cURL, Wget, PowerShell, and CMD with fast, reliable, zero-log endpoints.
Method 1: Find Public IP via cURL (Linux & macOS)
The fastest way to find public IP curl commands on Linux (Ubuntu, Debian, Fedora, Arch) or macOS is to query WhatMyIP.site's lightweight plain-text API. It returns only the clean IP address string, making it ideal for Bash variables and scripts:
curl https://whatmyip.site/api/ip
If your script requires structured metadata such as country, ISP, ASN, or coordinates, use the JSON endpoint:
curl -s https://whatmyip.site/api/json
You can pipe the JSON output into jq to extract specific fields directly into environment variables:
MY_IP=$(curl -s https://whatmyip.site/api/json | jq -r '.ip')
echo "Detected Public WAN IP: $MY_IP"
Testing Specific IPv4 vs IPv6 Connections
If your internet service provider offers dual-stack connectivity, you can force cURL to resolve over IPv4 or IPv6 specifically using flags:
curl -4 https://whatmyip.site/api/ip— Forces resolution over IPv4.curl -6 https://whatmyip.site/api/ip— Forces resolution over IPv6 (or errors if no IPv6 gateway exists).
Method 2: Check Public IP in Windows PowerShell
To check public ip powershell commands on Windows 10, Windows 11, or Windows Server, use the built-in Invoke-RestMethod cmdlet. Because it automatically parses JSON into a native PowerShell PSCustomObject, you can access properties instantly:
(Invoke-RestMethod -Uri "https://whatmyip.site/api/json").ip
To display network provider, city, and ASN in a formatted table inside PowerShell:
Invoke-RestMethod -Uri "https://whatmyip.site/api/json" | Format-List ip, isp, city, country, asn
Method 3: Check Public IP in Windows Command Prompt (CMD)
In modern versions of Windows 10 (build 17063+) and Windows 11, curl.exe is natively included out of the box in C:\Windows\System32. You do not need to install third-party packages:
curl https://whatmyip.site/api/ip
If you are on an older legacy Windows machine where cURL is unavailable, execute PowerShell inline directly from Command Prompt:
powershell -Command "(Invoke-RestMethod https://whatmyip.site/api/json).ip"
Method 4: Wget and HTTPie Snippets
For minimal server deployments where cURL is omitted, use standard wget:
wget -qO- https://whatmyip.site/api/ip
Or using the modern Python-based httpie CLI:
http https://whatmyip.site/api/ip
Public IP vs Local Private IP: Common Pitfall
A frequent source of confusion among developers is running ipconfig (Windows) or ifconfig / ip addr (Linux) and expecting to see their public IP. Those commands return your private local subnet IP (such as 192.168.1.105 or 10.0.0.12) assigned by your home router's DHCP server.
Because your router uses Network Address Translation (NAT) to multiplex dozens of local devices behind a single public connection, external web servers and remote peers only see your router's WAN IP. To troubleshoot local router configuration, explore our Router Gateway IP Directory, or audit your routing using our IP Lookup Tool.
Want to audit your network performance?
Test your internet speed, verify whether your connection leaks via WebRTC, or audit active DNS propagation: