How to Find Your PC's IP Address on Linux
Knowing your IP address on Linux is one of those tasks that sounds simple but branches into several different answers depending on what you actually need. Are you looking for your local network address? Your public-facing IP? A wired or wireless interface? Linux gives you multiple tools to check — and understanding which one to use matters.
What "IP Address" Actually Means on Linux
Before running any command, it helps to understand that your Linux machine likely has more than one IP address. There's:
- The local (private) IP address — assigned by your router, used within your home or office network. Typically starts with
192.168.x.x,10.x.x.x, or172.16.x.x. - The public IP address — assigned by your ISP, visible to the outside internet. Every device on your network shares this one.
- The loopback address — always
127.0.0.1, used internally by the system to communicate with itself. Not your actual network address.
Most people asking "what's my IP address on Linux" want the local IP for networking tasks, remote access, or troubleshooting — but the right answer depends on what you're trying to do.
The Main Commands to Show Your IP Address 🖥️
1. ip addr — The Modern Standard
ip addr This is the most reliable and widely supported command on modern Linux distributions (Ubuntu, Fedora, Debian, Arch, and others). It displays all network interfaces and their assigned addresses.
Look for your active interface in the output:
eth0orenp3s0— wired Ethernet connectionswlan0orwlp2s0— wireless (Wi-Fi) connectionslo— loopback (not your real IP)
The IPv4 address appears after inet, and the IPv6 address appears after inet6. For most home networking tasks, inet is what you want.
To filter the output and show only IPv4 addresses:
ip -4 addr To check a specific interface (e.g., Wi-Fi):
ip addr show wlan0 2. hostname -I — Quick and Clean
hostname -I This prints your machine's local IP address(es) without extra detail. It's fast, readable, and useful when you just need the number. If your machine has multiple interfaces active, it may return multiple addresses on the same line.
3. ifconfig — The Older Classic
ifconfig ifconfig was the go-to command for decades, but it's been deprecated on many modern Linux distributions. It may not be installed by default. If you get a "command not found" error, you'd need to install net-tools:
sudo apt install net-tools # Debian/Ubuntu sudo dnf install net-tools # Fedora/RHEL It works similarly to ip addr — look for inet under your active interface. For most current setups, ip addr is the better habit to build.
4. Finding Your Public IP Address
None of the above commands show your public IP — that requires reaching out to an external service. Common methods:
curl ifconfig.me curl icanhazip.com These query a web service and return the IP your internet traffic appears to originate from. This is useful when configuring remote access, firewalls, or external servers.
Comparing the Commands at a Glance
| Command | Shows Local IP | Shows Public IP | Pre-installed | Modern Standard |
|---|---|---|---|---|
ip addr | ✅ | ❌ | Usually yes | ✅ Yes |
hostname -I | ✅ | ❌ | Usually yes | ✅ Yes |
ifconfig | ✅ | ❌ | Often no | ❌ Deprecated |
curl ifconfig.me | ❌ | ✅ | Requires curl | ✅ Yes |
Variables That Affect What You See
Distribution and Version
Older Linux systems (pre-2012 era or long-term enterprise releases) may default to ifconfig-style tools. Modern distributions like Ubuntu 20.04+, Fedora 30+, and current Debian stable releases all ship with iproute2 — the package that provides ip addr.
Number of Active Interfaces
If your machine has both a wired and wireless connection active simultaneously, both ip addr and hostname -I will show multiple IP addresses. The interface names tell you which is which — but naming conventions vary slightly by distribution and whether predictable network interface naming is enabled.
Static vs. Dynamic (DHCP) Addresses
Most home and office networks assign IP addresses dynamically via DHCP, meaning your local IP can change when you reconnect or restart. Servers and systems configured with a static IP keep the same address. If you're setting up remote access or file sharing, this distinction matters significantly.
IPv4 vs. IPv6
Linux networks often run dual-stack, meaning your interface has both an IPv4 and an IPv6 address. ip addr shows both. Which one matters depends on how the service or device you're connecting to handles each protocol. 🌐
Virtual Machines and Containers
If you're running Linux inside a virtual machine (VirtualBox, VMware, WSL2 on Windows), the IP address displayed is often a virtualized address — not the same as your host machine's address, and not necessarily reachable the same way from other devices on your network.
When the Simple Answer Isn't Enough
For basic tasks — sharing files, setting up SSH, checking connectivity — ip addr or hostname -I gets you there quickly. But the moment your setup includes multiple interfaces, VPNs, containers, virtual machines, or specific routing requirements, the "right" IP address to use becomes context-dependent.
Your network configuration — how many interfaces are active, whether you're on a routed or bridged connection, and what you're trying to reach — is ultimately what determines which address is the one that matters for your situation.