Finding an IP address using the command prompt is a fundamental skill for diagnosing network issues, verifying connectivity, and understanding how your device interacts with a network. Whether you are troubleshooting a home router or managing enterprise infrastructure, the command line provides a direct and efficient way to access this critical information without relying on graphical interfaces.
Understanding IP Addresses and the Command Prompt
An IP address serves as a unique identifier for devices on a network, enabling communication across local and global systems. The command prompt, or terminal, acts as a powerful interface to interact directly with the operating system's networking stack. By utilizing specific commands, users can retrieve configuration details, verify active connections, and resolve potential conflicts instantly.
Using the ipconfig Command on Windows
On Windows operating systems, the ipconfig command is the primary tool for displaying all current TCP/IP network configuration values. This command provides a clear overview of your IPv4 and IPv6 addresses, subnet masks, and default gateway information.
Open the Command Prompt by searching for cmd in the Start menu.
Type ipconfig and press Enter to execute the command.
Locate the section for your active network adapter, such as "Wireless LAN adapter Wi-Fi" or "Ethernet adapter Local Area Connection."
The "IPv4 Address" field will display the private IP address assigned to your device.
Using the ifconfig and ip Commands on macOS and Linux
Unix-based systems like macOS and Linux offer a slightly different approach, though the goal remains the same. While ifconfig was traditionally used, many modern distributions now rely on the more powerful ip command.
To find your IP address, open the Terminal application and enter the appropriate command. The output will list all interfaces, with the active one showing the assigned IP under the "inet" field for IPv4 or "inet6" for IPv6 addresses.
Finding Public IP Addresses
While the commands above reveal your private IP address within your local network, there are times when you need to identify your public IP address—the address seen by the internet. This is often necessary for configuring remote access, setting up servers, or verifying your ISP connection.
Although this task typically involves external websites, you can leverage the command prompt itself to query a reliable third-party service. By using utilities like curl or wget , you can fetch your public IP directly into the terminal window.
For Linux and macOS, type curl ifconfig.me and press Enter.
Windows 10 and 11 users with the Windows Subsystem for Linux (WSL) installed can use the same command.
Alternatively, curl api.ipify.org provides the same result in a more explicit format.