WhatMyIP.site
CLI & Automation 5 min read

How to Find Your Public IP Address Using Linux Terminal, PowerShell, and CMD

Marcus Vance Written by Marcus Vance (Lead Network Infrastructure Engineer) • Reviewed by Elena Rostova, CISSP • Updated October 2026

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.

Your Current Visible Connection
Public IP: 66.249.66.1
Provider: Google LLC • Location: Mountain View, United States
Full Diagnostic Trace IP

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:

# 1. Instant plain-text public IP
curl https://whatmyip.site/api/ip

If your script requires structured metadata such as country, ISP, ASN, or coordinates, use the JSON endpoint:

# 2. JSON formatted metadata
curl -s https://whatmyip.site/api/json

You can pipe the JSON output into jq to extract specific fields directly into environment variables:

# 3. Parse specific fields with jq
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:

# PowerShell One-Liner (Returns String)
(Invoke-RestMethod -Uri "https://whatmyip.site/api/json").ip

To display network provider, city, and ASN in a formatted table inside PowerShell:

# Detailed PowerShell Diagnostic Object
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:

# Windows CMD (Command Prompt)
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:

# CMD Calling PowerShell Engine
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 (Quiet mode output to stdout)
wget -qO- https://whatmyip.site/api/ip

Or using the modern Python-based httpie CLI:

# HTTPie
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:

Full IP Diagnostic Trace IP Geolocation Speed & Ping Test VPN Checker
Marcus Vance

Marcus Vance

CCNP Enterprise Verified Author
Lead Network Infrastructure Engineer

Marcus has 12+ years optimizing Anycast DNS routing, BGP peering, and solving complex ISP network errors. He specializes in deterministic command-line diagnostics.

View all guides by Marcus