Finding the IP address of your machine using the command prompt is a fundamental skill for troubleshooting network issues, verifying connections, and managing servers. The Command Prompt on Windows and the Terminal on macOS and Linux provide direct access to the system's networking stack, allowing you to retrieve this information instantly without navigating through graphical settings. This process relies on powerful built-in utilities that display network configuration data, and understanding how to use them gives you greater control over your network diagnostics.
Using ipconfig on Windows
On Windows systems, the primary tool for displaying IP address information is the ipconfig command. This utility shows detailed configuration for all network adapters installed on your computer, including Ethernet and wireless connections. To open Command Prompt, you can press the Windows key, type "cmd," and press Enter. Once the window appears, typing ipconfig and pressing Enter will generate a list of your network interfaces along with their current IP addresses, subnet masks, and default gateways.
Interpreting the Output
When you run the basic command, the output is divided into sections for each network adapter. Look for the section labeled "Ethernet adapter" or "Wireless LAN adapter," depending on your connection type. Under these headings, the line labeled "IPv4 Address" displays the numerical address you are seeking. This is typically a series of four numbers separated by dots, such as 192.168.1.10, and it represents the local address assigned to your device on the network.
Using ip a on Linux and macOS
While Windows uses ipconfig , Unix-based systems like Linux and macOS rely on the ifconfig command, although many modern distributions have deprecated it in favor of the ip command line tool. To view network interface details, you can open the Terminal and type ip a or ip address . This command provides a comprehensive view of all network interfaces, including their state (up or down) and associated IP addresses.
Filtering for Specific Information
The output of ip a is very verbose, showing packet statistics and configuration details. To quickly locate the IP address, focus on the lines labeled "inet" for IPv4 addresses or "inet6" for IPv6 addresses. The inet line will show the IP address followed with a slash and a number, which indicates the subnet mask in CIDR notation. For example, an address listed as 192.168.1.15/24 indicates a standard Class C network with a 24-bit subnet mask.
Finding the Public IP Address
It is important to distinguish between the local IP address, which is used within your private network, and the public IP address, which is assigned by your Internet Service Provider and is visible to the outside world. The commands mentioned so far only display the local address. To find the public IP address using the command line, you must query an external server. This is useful for verifying port forwarding, checking firewall settings, or identifying your network's address to share with remote services.
Utilizing External Services
You can leverage command-line tools like curl or wget to fetch your public IP from a web service. By piping the response directly to the console, you get a clean, human-readable result. Common commands include curl ifconfig.me or wget -qO- ifconfig.me . These commands contact a remote server, which responds with your public-facing IP address, effectively bypassing the local network configuration to give you the view seen by the internet.