To find your IP address via the command line, use ipconfig on Windows or ifconfig or ip addr on macOS and Linux. These commands query your network interface controller to display the current network configuration, including your local IPv4 and IPv6 addresses, subnet mask, and default gateway.
What You'll Need
- A computer with an active network connection (Wi-Fi or Ethernet).
- Access to the command line interface (Terminal or Command Prompt).
- Administrative privileges (only required for certain advanced network changes, not for viewing your IP).
Step-by-Step
Depending on your operating system, the commands and the interface used to enter them differ. Follow the section corresponding to your device.
Windows (Command Prompt or PowerShell)
- Press the Windows Key + R on your keyboard to open the Run dialog box.
- Type
cmdinto the text field and press Enter. This opens the Command Prompt. Alternatively, you can right-click the Start button and select Windows Terminal or PowerShell. - In the black window, type
ipconfigand press Enter. - Look through the output for the section labeled Ethernet adapter (if you are plugged in via cable) or Wireless LAN adapter Wi-Fi (if you are on wireless).
- Locate the line that says IPv4 Address. The numbers next to it (e.g., 192.168.1.15) are your local IP address on your home or office network.
- To see more detailed information, including your physical MAC address and DNS servers, type
ipconfig /alland press Enter.
macOS (Terminal)
- Open Spotlight Search by pressing Command + Space.
- Type
Terminaland press Enter to launch the command line interface. - To find your IP address for a specific connection, type
ifconfigand press Enter. - The output will show several interfaces. Look for
en0(usually Wi-Fi) oren1(usually Ethernet). - Find the word
inetfollowed by a series of numbers. This is your local IPv4 address. Ignoreinet6, which is your IPv6 address. - Alternatively, for a cleaner output that only shows the IP, you can use the command
ipconfig getifaddr en0(replacing en0 with your active interface).
Linux (Terminal)
- Open your terminal emulator (usually Ctrl + Alt + T in most distributions).
- Type
ip addr show(or simplyip a) and press Enter. This is the modern standard for Linux networking. - Look for the network interface you are currently using, such as
eth0for Ethernet orwlan0for Wi-Fi. - Locate the
inetline under that interface. The address listed there is your local IP. - If your system is older and does not support the
ipcommand, try typingifconfig. If it is not installed, you may need to install thenet-toolspackage via your package manager.
Finding Your Public IP Address
The steps above provide your Private IP, which is how your router identifies your device within your home. To find your Public IP (how the rest of the internet sees your network) via the command line, you must query an external server because your computer does not "know" its public IP—the router handles that.
- Open your command line tool (CMD, Terminal, or Bash).
- Type the following command:
curl ifconfig.me(orcurl icanhazip.com). - Press Enter. The system will send a request to a remote server, which will then echo back your public-facing IP address.
Common Mistakes
One of the most frequent errors is confusing the Loopback Address with the actual network IP. When running ipconfig or ifconfig, you will often see an address like 127.0.0.1. This is the localhost address; it refers to the computer itself and cannot be used by other devices to find you on a network. Always look for the adapter specifically labeled "Wi-Fi" or "Ethernet."
Another common mistake is typing the command incorrectly. For example, Windows users often try to use ifconfig, which is a Unix/Linux command and will return an "is not recognized as an internal or external command" error. Conversely, Linux users may try ipconfig, which will similarly fail. Ensure you are using the command specific to your operating system.
Users also frequently confuse their IPv4 and IPv6 addresses. IPv4 addresses are four sets of numbers separated by dots (e.g., 192.168.0.1). IPv6 addresses are much longer, containing hexadecimal characters separated by colons. While IPv6 is the newer standard, most home networking tools and port-forwarding settings still rely on IPv4.
Tips
If you find yourself needing your IP address frequently for development or server management, you can create an alias. On macOS or Linux, you can add alias myip='curl ifconfig.me' to your .bashrc or .zshrc file. This allows you to simply type myip to get your public address instantly without remembering the full URL.
When analyzing the ipconfig /all output on Windows, pay close attention to the Default Gateway. This is the IP address of your router. If you are having connectivity issues, trying to ping the default gateway is the first step in determining if the problem is between your computer and the router, or between the router and the internet.
For those managing multiple network adapters (such as a VPN and a physical Wi-Fi card), the command line will list all of them. A VPN usually creates a "Virtual Adapter." If you see multiple IP addresses, the one associated with the VPN adapter is the one the internet sees when the VPN is active, while the physical adapter IP remains your local identity on the home network.
Troubleshooting
The command returns "Not Recognized" or "Command Not Found"
This usually happens because of a typo or because you are using a command from the wrong OS. Double-check that you are using ipconfig for Windows and ip addr or ifconfig for Linux/macOS. On some minimal Linux installations, ifconfig is not installed by default; use ip a instead.
The IP address is 169.254.x.x
If your IPv4 address starts with 169.254, this is an Automatic Private IP Address (APIPA). This means your computer was unable to contact a DHCP server (your router) to obtain an IP address. Check your physical cable connection or ensure your Wi-Fi password is correct. Restarting your router often resolves this.
The output is too long and scrolls off the screen
On Linux and macOS, you can pipe the output to a pager to scroll through it more easily. Use ifconfig | less. This allows you to use the arrow keys to move up and down. Press q to exit the view.
The curl command for public IP fails
If curl is not installed or the server is down, try an alternative service. Instead of curl ifconfig.me, try curl api.ipify.org. If you are on Windows and curl is not working (in older versions of Windows 10), you can use the browser or install curl via a package manager.
Frequently Asked Questions
Is my IP address the same on every device?
No. Each device on your local network (phone, laptop, smart TV) has its own unique Private IP assigned by the router. However, all devices sharing the same internet connection will typically share the same Public IP when communicating with the outside world.
Can someone find my physical location using my IP?
A public IP address can provide a general geographic location (such as your city or ISP region), but it cannot pinpoint your exact street address or house number without access to the ISP's private logs.
What is the difference between a static and dynamic IP?
A dynamic IP is assigned by the router and can change over time or after a reboot. A static IP is manually assigned to a device and never changes, which is useful for hosting servers or printers.
Why does my IP address change?
Most home networks use DHCP (Dynamic Host Configuration Protocol), which "leases" IP addresses for a set period. When the lease expires or the router restarts, the device may be assigned a different address from the available pool.
Do I need admin rights to see my IP?
No, viewing your network configuration is a read-only action and does not require administrative or root privileges on any major operating system.
What is a subnet mask?
The subnet mask (often 255.255.255.0) defines which part of the IP address refers to the network and which part refers to the specific device. It helps the computer determine if another IP address is on the same local network or needs to be sent to the gateway.