To see your current IP address in the command line, you’re already one step ahead—just run the correct line for your OS. On Windows, Linux, or macOS, this works instantly. No extra software needed, just type the command that matches your system.
What You'll Need
- Your operating system (Windows, macOS, or Linux).
- A terminal or command prompt window open (Ctrl+Alt+T on Linux/macOS, Win+R on Windows).
- Basic knowledge of your OS’s command syntax (no advanced skills required).
Step-by-Step
- On Windows:
- Open a new Command Prompt window (press
Win+R, typecmd, and hit Enter). - Type the following command and press
Enter:ipconfig - Look for the
IPv4 Addressunder your active network adapter (Wi-Fi or Ethernet). If you’re unsure which adapter to use, check the name—it will say something likeEthernet Connection 2orWi-Fi.
- Open a new Command Prompt window (press
- On macOS or Linux (macOS/Linux):
- Open Terminal (Ctrl+Alt+T or search for "Terminal" in your apps).
- Run one of these commands to display your IP address:
ifconfig | grep 'inet 'or (for newer Linux/macOS versions):ip aand search forinetin the output. - Look for the line that starts with
inet 192.x.x.xor similar (your local IP). For your public IP (visible on the internet), use:curl ifconfig.meto fetch it directly from an online service.
Common Mistakes
- Windows: "No IP Address Found" Your device might not have an active network connection. Check your Wi-Fi or Ethernet cable is plugged in. If using mobile data, ensure it’s turned on in your network settings.
- macOS/Linux: Terminal errors like "Error: Address not available"
This could mean no network is active. Try restarting your router or running:
sudo ifconfig en0 up(replaceen0with your interface name by runningip afirst). - Both OSes: Wrong command syntax
Forgetting to run
ipconfig(Windows) or using an outdated command likenetstat(which shows connections, not IP). Always use the exact command above.
Tips
- Public vs. Private IP
The commands above show your private IP (local network). To get your public IP (visible to the internet), use:
curl ifconfig.me(macOS/Linux) or search "what is my public IP" in CMD (Windows). - Multiple adapters?
If you have both Wi-Fi and Ethernet, run
ipconfig(Windows) orip a(macOS/Linux) to see which adapter is active. The correct one will show an IP like192.168.x.xor10.x.x.x. - Avoid third-party tools
Using websites like "whatismyip.com" is fine, but for command-line speed,
curl ifconfig.meis faster and reliable. - Check network status If the command shows no IP, your network might be down. Restart your router or check the light on your modem.
Troubleshooting
If your system isn’t showing an IP address at all, start with these checks:
- Test your internet connection Open a browser and visit google.com. If this fails, your connection is broken. Reboot your router or check cables.
- Reset network settings (macOS/Linux)
Run these commands to restore default settings:
sudo ifconfig en0 unset netaddr netmask broadcastThen restart your device. For Windows, go to:Settings > Network & Internet > Ethernet/Wi-Fi > Change adapter options> Right-click your adapter > Properties > Uncheck IPv4/IPv6 and re-enable it. - Update your OS
Outdated drivers or OS versions can cause network issues. Update via your device’s update settings (Windows:
Settings > Windows Update; macOS:System Preferences > Software Update). - Try another command
If
ipconfig(Windows) orifconfig(macOS) fails, use:ping 8.8.8.8(Terminal/CMD). If this works, your issue is likely with the IP command, not the internet. - Last resort: Factory reset If nothing works, reset your router to factory defaults (find the reset button on the back) and reconnect your device. This clears all network settings.
Frequently Asked Questions
How do I find my public IP address via command line?
Use curl ifconfig.me (macOS/Linux) or search "what is my public IP" in CMD (Windows). This fetches your IP directly from an external service.
Why does my terminal show "No address assigned" and I can still browse the web?
This happens if your device has a default gateway but no IP. Try pinging 8.8.8.8—if it works, your OS needs manual IP assignment. On macOS/Linux, run sudo dhclient en0 (replace en0 with your interface). On Windows, go to Settings > Network & Internet > Ethernet/Wi-Fi > Change adapter options > Right-click your adapter > Properties > IPv4 > Obtain an IP automatically.
Can I use these commands on Raspberry Pi?
Yes! Raspberry Pi uses Linux-based OSes. Run ip a to see all interfaces, then look for inet under your Wi-Fi/Ethernet adapter.
What if I don’t have a network adapter (e.g., a headless server)?
On a server without a GUI, use ifconfig (older systems) or ip a (newer Linux). If no adapter is listed, your system may not have network support. Check /etc/network/interfaces (Debian/Ubuntu) or /etc/sysconfig/network-scripts/ifcfg-eth0 for manual config.
Why does my IP change every time I run the command?
This happens if you’re on a shared network (like a hotel Wi-Fi) or using DHCP. The command shows your current assignment. To see if it’s dynamic, run route -n (Linux/macOS) or check the Default Gateway in ipconfig (Windows).
How do I check my IP if I’m using a VPN?
VPNs change your IP to one associated with their server. To see your real public IP (before VPN), use curl ifconfig.me from a browser or command line without VPN. If this fails, your VPN might be interfering—test with a different service like curl icanhazip.com.
Need more details on your specific system? Let me know your OS and model, and I’ll refine the steps.