How to View Your IP Address in Linux
Knowing your IP address in Linux isn't just a sysadmin task — it's something anyone running a Linux machine will eventually need to do, whether for troubleshooting a network issue, configuring a server, or setting up remote access. The good news: Linux gives you multiple reliable ways to find it. The less obvious part is knowing which IP address you're looking for, and which tool gives you the most accurate picture of your setup.
What "IP Address" Actually Means on a Linux System
Before running any command, it helps to understand that your Linux machine likely has more than one IP address — and they're not interchangeable.
- Loopback address (
127.0.0.1): This is the address your system uses to talk to itself. You'll always see it, and it's never your real network address. - Private (local) IP address: This is the address assigned to your machine within your local network — by your router or DHCP server. It's what other devices on the same network use to reach you.
- Public IP address: This is the address the wider internet sees. It belongs to your router, not your machine directly, and you won't find it with a local terminal command alone.
Most people asking "how do I find my IP address in Linux" want the private IP — the one assigned to their network interface (Ethernet or Wi-Fi).
The Modern Method: ip Command 🖥️
The ip command is the current standard on most Linux distributions, replacing the older ifconfig tool that has been deprecated for years.
To view your IP address, open a terminal and run:
ip addr show Or the shorthand version:
ip a This outputs detailed information about every network interface on your system. You're looking for entries under interfaces like eth0, ens33, wlan0, or enp3s0 — the naming convention varies by distribution and system configuration.
Within each interface block, look for the line starting with inet followed by an address in the format 192.168.x.x or 10.x.x.x. That's your private IPv4 address. If you see a line starting with inet6, that's your IPv6 address.
To filter the output and show only the IPv4 address for a specific interface, you can use:
ip -4 addr show eth0 Replace eth0 with your actual interface name.
The Older Method: ifconfig
On older Linux systems — or distributions where the net-tools package is still installed — ifconfig still works:
ifconfig The output is formatted differently but contains the same information. Look for your interface name and the inet value beneath it.
If ifconfig returns a "command not found" error on your system, it's not installed. You can either install net-tools via your package manager or simply use ip addr instead.
Hostname-Based Method
Another quick approach uses the hostname command:
hostname -I This returns the IP address (or addresses) assigned to your machine without additional interface details. It's fast and clean, though it gives less context about which interface each address belongs to. Useful when you just need the number and nothing else.
Finding Your Public IP Address
None of the local commands above will show your public IP — the address your internet traffic appears to come from. For that, you need to query an external service. From the terminal:
curl ifconfig.me Or:
curl icanhazip.com These send a request to a third-party server that reflects your public IP back to you. This requires an active internet connection and trusts that external service with a lookup request — something worth noting in privacy-sensitive environments.
Comparing the Main Methods at a Glance
| Method | Command | Shows Private IP | Shows Public IP | Notes |
|---|---|---|---|---|
ip command | ip addr show | ✅ | ❌ | Modern standard, always available |
ifconfig | ifconfig | ✅ | ❌ | Older, may need installation |
hostname | hostname -I | ✅ | ❌ | Quick output, less detail |
curl external | curl ifconfig.me | ❌ | ✅ | Requires internet access |
Variables That Affect What You See
The output you get depends heavily on your specific setup:
- Interface naming: Older systems use
eth0/wlan0. Newer systems using systemd often use predictable names likeenp2s0orwlp3s0. The names differ by hardware and distro. - Multiple interfaces: Machines with both wired and wireless connections — or virtual machines with bridged networking — will show multiple IPs. Knowing which interface you're troubleshooting matters.
- DHCP vs. static: A dynamically assigned IP can change after a reboot or lease renewal. A statically configured IP won't.
- IPv4 vs. IPv6: Modern Linux systems often have both.
inetis IPv4;inet6is IPv6. Some networks run dual-stack, some don't. - Virtual machines and containers: Docker, VirtualBox, and similar environments add virtual network interfaces with their own IP ranges, which can make the output more complex to read.
💡 A Note on Permissions
Most IP-viewing commands work without root privileges. You don't need sudo to run ip addr show or hostname -I. Some older network tools or certain interface configurations may behave differently, but for standard IP lookups, a regular user account is sufficient.
The right command for your situation depends on what you're actually trying to accomplish — whether that's diagnosing a connectivity issue, configuring a firewall rule, setting up SSH access, or something else entirely. Each of those scenarios points you toward different parts of the output, and sometimes toward different tools altogether.