To see your public or local IP address from the terminal, you don’t need any extra tools—just a few direct commands. On Linux/macOS, open a terminal (press `Ctrl+Alt+T` or search for “Terminal” in your apps). On Windows, open Command Prompt (`Win + R` > type `cmd`) or PowerShell. Here’s how to get your IP address reliably, along with troubleshooting tips if it doesn’t work as expected.
What You'll Need
- A terminal or command prompt open (no special software required)
- Your internet connection active (Wi-Fi or Ethernet)
- Basic familiarity with typing commands (no advanced skills needed)
Step-by-Step
-
For public IP (visible to the internet):
Run this command in your terminal:
curl ifconfig.meorwget -qO- ifconfig.me(This fetches the IP from a website and displays it immediately.) Works on Linux/macOS/Windows Terminal/PowerShell. If you’re on Windows CMD, use the first command. -
For local IP (your router-assigned address):
Try one of these commands:
ip a(Linux/macOS)ipconfig(Windows CMD)ifconfig(macOS/Linux, may require `sudo` for all interfaces)
inetorinet6—your gateway (router) IP will match your device’s local address. For example, on Linux, you’ll see lines like:inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic wlan0(Ignore the192.168.x.xrange; that’s your router’s local IP.) -
For IPv6 (alternative to IPv4):
Use:
ip -6 a(Linux/macOS) oripconfig /all(Windows CMD, filter for IPv6 lines). Look forinet6under your active network interface.
Common Mistakes
-
Command not recognized:
If
ifconfigoripconfigfails, install tools likenet-tools(Linux) or enable IPv6 in Windows first. On macOS, runsudo ifconfigwith admin rights. - No internet connection: Run these commands when connected (Wi-Fi or Ethernet). If you’re on a VPN or proxy, the IP may appear altered.
-
Typo in commands:
Example errors:
ifconfigg(missing ‘f’) orip -6(Linux requiresip -6 a).
Tips
-
Multiple IPs?
Your device may have multiple addresses (e.g., a VPN adds a new IP). Ignore non-
inetlines unless you’re troubleshooting a specific interface. -
Windows CMD vs PowerShell:
PowerShell sometimes shows cleaner output (e.g.,
Get-NetIPAddress). Use PowerShell for IPv6 details. - Check your ISP’s block: If the IP matches a known ISP range (e.g., 100.64.0.0/10), you’re behind NAT. Public IPs are usually unique (e.g., 203.0.113.45).
-
Port forwarding?
Use
curl ifconfig.coorwget -qO- ipinfo.io/ipfor a more reliable public IP (less likely to be blocked).
Troubleshooting
If the command doesn’t return an IP, check these steps in order:
- Restart your terminal: Close and reopen it. Old cached data may cause issues.
-
Test connectivity:
Ping a public site:
ping google.comIf this fails, your network is disconnected. Try restarting your router or switching from Wi-Fi to Ethernet. -
Update tools:
On Linux, upgrade
ipandnet-tools:sudo apt update && sudo apt upgrade -yOn Windows, update Windows 10/11 via Settings > Update & Security. - Disable VPN/proxy: VPNs or proxies can alter your IP. Temporarily disable them before running the command.
Frequently Asked Questions
1. Why does my local IP start with 192.168.x.x or 10.x.x.x?
These are private IP ranges assigned to home networks (192.168, 10.x.x, 172.16.x–172.31.x). Public IPs start with 64.x.x.x (RFC 1918) and are unique across the internet. Your device’s local IP is the one your router assigns to you.
2. How do I find my public IP without internet?
You can’t—public IPs require an active internet connection. If you’re offline, use a local IP (e.g., 192.168.1.100) and manually check your router’s settings (usually at 192.168.1.1 by default).
3. Why is my public IP wrong after using a VPN?
The VPN assigns you a new public IP (usually in a different country). To check, run curl ifconfig.me or wget -qO- ifconfig.co while connected.
4. How do I check if my IP is being blocked by a firewall?
Test if your internet works normally (e.g., ping 8.8.8.8). If commands fail but basic browsing works, your firewall may restrict terminal access. Temporarily disable it to check.
5. What if my terminal doesn’t show IPv6?
Windows 10/11 and newer support IPv6 by default. On Linux/macOS, ensure IPv6 is enabled:
sudo sysctl -w net.ipv6.conf.all.enable=1
Then restart the terminal.
6. Can I find my IP in Windows Explorer?
No. Only command-line tools or third-party apps (like ipconfig.net) show IPs directly. The terminal is the most reliable method.
Note: For security systems, always use the terminal to verify IPs before configuring firewalls or port forwarding. Avoid trusting public IP lists from untrusted sources.