Finding your IP address on Linux is a fundamental skill for troubleshooting network issues, configuring servers, or simply understanding how your machine connects to the internet. The operating system provides several straightforward methods to retrieve this information, ranging from graphical tools to command-line utilities.
Understanding IP Address Types
Before diving into the commands, it is essential to distinguish between the two primary types of IP addresses your Linux machine utilizes. Your system can have multiple addresses assigned to different network interfaces, and confusing them can lead to incorrect results.
Private vs. Public IPs
A private IP address is used within your local network, such as your home router or office network, and is not routable on the public internet. This is typically an address starting with 192.168, 10, or 172.16–172.31. In contrast, a public IP address is the global address assigned to your router by your Internet Service Provider (ISP), which allows you to communicate with the rest of the internet. When people ask how to find "my IP," they are usually referring to the public address.
Using the IP Command
The most modern and versatile tool for network configuration on Linux is the ip command. It replaces the older ifconfig utility and provides detailed information about your network interfaces.
Finding the Local Address
To see all IP addresses assigned to your network interfaces, open your terminal and type the following command:
ip addr show
This command outputs a list of interfaces (like eth0 for Ethernet or wlan0 for Wi-Fi) along with their associated inet addresses. Look for the inet label followed by an address to find your private IP.
Finding the Public IP Address
While the ip command shows your local network configuration, it does not display your public IP. To retrieve the address seen by the internet, you must query an external server designed to echo back your connection details.
Using Command-Line Utilities
There are several reliable command-line tools specifically designed to fetch your public IP. These tools contact a remote server which returns your IP as plain text, making it easy to use in scripts or copy-paste operations.
curl ifconfig.me
wget -qO- ifconfig.me
curl ident.me
These commands are simple but effective, relying on third-party websites to determine what IP address your requests are originating from.
Graphical Interface Methods
Not all users are comfortable with the terminal, and Linux provides intuitive graphical ways to find your IP address without typing commands.
Desktop Environment Settings
You can usually find your IP by navigating through your system settings. The exact path varies depending on your distribution and desktop environment (GNOME, KDE, XFCE, etc.), but the general process is consistent:
Open the "Settings" application.
Navigate to "Network" or "Connections."
Select the active network connection (Wi-Fi or Wired).
Look for the "Details" or "IPv4" section, where the address is listed.
Verifying DNS Configuration
Sometimes users confuse their IP address with DNS servers. While finding the IP tells you where your machine is located on the network, checking your DNS reveals how your machine translates domain names like google.com into those IPs.