Finding your IP address from the command prompt helps troubleshoot networks and verify server connectivity. This guide walks through practical steps using common command line tools.
Whether you use Windows, macOS, or Linux, the command prompt provides direct ways to reveal your local and public IP information. The following sections explain methods, flags, and what each output value means.
| Platform | Command | Shows | Use Case |
|---|---|---|---|
| Windows | ipconfig | Local IPv4 and IPv6 addresses | Quick local address check on Windows |
| macOS and Linux | ifconfig or ip addr | Interface details including local IP | Inspect network interfaces and masks |
| Any OS with curl | curl ifconfig.me | Public IP address as seen online | Verify outbound public IP and NAT setup |
| Linux systems | hostname -I | All non-loopback local IPs | Script-friendly one line output |
| PowerShell | Get-NetIPAddress | Detailed IP address properties | Filter by address family and interface |
Using ipconfig to Find IP Address on Windows
On Windows, the ipconfig command is the standard way to view network configuration. It displays adapter details, subnet masks, default gateway, and DNS servers in a concise list.
Open Command Prompt or PowerShell and type ipconfig to see IPv4 and IPv6 addresses assigned to your active interfaces. Look for the section matching your Ethernet or Wi-Fi adapter to locate the local IP.
You can refine the output with findstr to quickly highlight the IP line. For example, ipconfig | findstr /i "ipv4" filters results to only lines containing IPv4 addresses.
Finding IP Address on macOS and Linux
macOS and Linux provide ifconfig and the more modern ip addr commands to inspect network interfaces. These commands show link status, MAC address, subnet, and assigned IPs.
Run ip addr show to list all interfaces and their IP assignments, or if you prefer a shorter form, use hostname -I to print all non-loopback IPs on one line. This is handy for scripts that need a clean, parseable output.
For quick public IP checks, curl ifconfig.me returns only the outward facing IP address, which is helpful when testing NAT or firewall behavior.
Interpreting Command Output and Interface Names
Understanding interface names such as eth0, en0, or Wi-Fi helps you map commands to the correct network connection. Each interface can have multiple addresses, including link-local, private, and public aliases.
Flags like inet in ip addr indicate IPv4 addresses, while inet6 signals IPv6. The scope global marks addresses that are reachable beyond the local link, whereas scope link refers to address used only on the local segment.
Cross reference the interface name with your physical or virtual adapters to confirm you are reading the correct network path for your device.
Using Command Options to Filter and Format
Both Windows and Unix style tools offer options to narrow down results. Adding parameters such as -4 or -6 to ip commands restricts output to specific address families.
PowerShell cmdlets like Get-NetIPAddress allow filtering by -AddressFamily and -InterfaceAlias, giving precise control over which data appears. This is valuable in automated troubleshooting or logging scripts.
Combining command output with text processing tools such as grep, awk, or select-string lets you extract only the IP address portion for further use.
Best Practices for Command Prompt IP Discovery
- Verify the correct interface name before filtering output to avoid reading the wrong address.
- Use curl ifconfig.me or similar services to confirm your public IP when behind NAT or proxy.
- Prefer ip addr or Get-NetIPAddress for detailed information and easier parsing in scripts.
- Document the commands and expected output for faster troubleshooting across teams.
- Test commands on each platform you support to ensure compatibility and consistent formatting.
FAQ
Reader questions
How do I find my local IP address using the command prompt?
Use ipconfig on Windows, ifconfig or ip addr on macOS and Linux to display the IP assigned to your network adapter.
How can I check my public IP from the command line?
Run curl ifconfig.me in any terminal that has internet access and curl installed to see your public IP as seen from the web.
What does the 'inet' label mean in ip addr output?
The label inet indicates an IPv4 address assigned to the interface, while inet6 refers to an IPv6 address. Yes, use hostname -I on Linux or combine curl ifconfig.me with text tools to return a clean, script-friendly IP string.