How to Find Your IP Address in Linux: Commands and Methods Explained
Knowing your IP address in Linux is one of those tasks that sounds simple but has more layers than most people expect. Whether you're troubleshooting a network issue, configuring a server, or just getting oriented on a new machine, the right answer depends on which IP address you're actually looking for — and Linux gives you several ways to find it.
What "IP Address" Actually Means on a Linux System
Before running any command, it helps to understand that your Linux machine may have multiple IP addresses at once. Every network interface gets its own address, and there are two fundamentally different types:
- Private (local) IP address — assigned to your machine within your home, office, or server network. This is what other devices on the same network use to reach you.
- Public (external) IP address — assigned by your Internet Service Provider. This is what the outside world sees when you connect to the internet.
These are not the same number, and commands run locally will return your private IP, not your public one.
There's also the loopback address (127.0.0.1), which is a special internal address every Linux system uses to talk to itself. You'll see it in most outputs — it's not your real network address.
🖥️ Method 1: Using the ip Command (Modern Standard)
The ip command is the current standard tool on most Linux distributions. It replaced the older ifconfig tool and is available by default on Ubuntu, Debian, Fedora, CentOS, Arch, and most others.
ip addr show Or the shorthand version:
ip a This outputs all network interfaces and their assigned addresses. Look for entries like eth0, ens33, enp3s0 (wired connections) or wlan0, wlp2s0 (wireless). Under each interface, you'll see a line beginning with inet followed by your IPv4 address, and inet6 for your IPv6 address.
To filter for just IPv4 addresses across all interfaces:
ip -4 addr show To check a specific interface only (replace eth0 with your interface name):
ip addr show eth0 Method 2: Using hostname for a Quick Lookup
If you just need your machine's primary IP address and don't want to parse through full interface output, this command is faster:
hostname -I This prints all IP addresses assigned to the host, space-separated, without extra detail. It's useful in scripts or when you just need a quick number.
Note: hostname -I (capital I) returns IP addresses. hostname -i (lowercase) may return the loopback address on some systems, which isn't what you typically want.
Method 3: Using ifconfig (Older but Still Common)
On older distributions — or systems where the net-tools package is installed — ifconfig still works:
ifconfig The output format is different from ip, but the logic is the same: find your active network interface and read the inet line. If ifconfig returns a "command not found" error, it's not installed. On Debian/Ubuntu systems, you can install it with:
sudo apt install net-tools Whether to use ifconfig or ip often comes down to habit and what's available on your system — but ip is the direction Linux networking has moved.
🌐 Method 4: Finding Your Public IP Address
None of the commands above reveal your public IP. For that, you need to query an external service. These work from the terminal:
curl ifconfig.me curl icanhazip.com curl ipinfo.io/ip All three reach out to a web service that responds with the IP address your request arrived from — which is your public-facing IP. You'll need an active internet connection and curl installed (it's available by default on most distributions).
Comparing the Main Methods
| Method | Command | Shows Private IP | Shows Public IP | Notes |
|---|---|---|---|---|
ip command | ip a | ✅ | ❌ | Modern standard, detailed output |
hostname | hostname -I | ✅ | ❌ | Quick, minimal output |
ifconfig | ifconfig | ✅ | ❌ | Older tool, may need installation |
| curl service | curl ifconfig.me | ❌ | ✅ | Requires internet access |
Variables That Affect What You See
The output from any of these commands will vary based on several factors:
- Number of network interfaces — a machine with both wired and wireless connections will show multiple entries, each with its own IP
- Static vs. dynamic addressing — if your machine uses DHCP, the IP address may change between sessions; static IPs remain fixed
- Virtual machines and containers — Docker, VirtualBox, and similar tools create additional virtual network interfaces, which will appear alongside real ones
- Linux distribution and version — some minimal or embedded distributions may not include all tools by default
- Network configuration — systems on a VPN will show additional interface addresses, and VPN traffic may affect which public IP external services report back
What IPv4 vs. IPv6 Means for Your Output 🔢
Modern Linux systems are configured for both IPv4 (the familiar four-number format like 192.168.1.10) and IPv6 (longer hexadecimal format like fe80::1a2b:3c4d:5e6f:7a8b). You may see both in your output for the same interface.
Which one matters to you depends on your network setup, your router's configuration, and what you're using the address for. Many home and small-office networks primarily use IPv4 internally, while IPv6 adoption at the ISP level varies widely.
The right IP address to use — private or public, IPv4 or IPv6, from which interface — ultimately comes down to what you're trying to do with it and how your specific network is set up.