How to Find Your IP Address on Linux

Whether you're troubleshooting a network issue, configuring a server, or setting up a remote connection, knowing how to find your IP address on Linux is a fundamental skill. Linux gives you several ways to check this — some built into every distribution, others depending on what tools are installed. Understanding what each method returns, and why the results can differ, is just as important as running the commands themselves.

What "IP Address" Actually Means on Linux

Before running any command, it helps to know that Linux systems can have multiple IP addresses at the same time. Every network interface — wired, wireless, virtual, or loopback — gets its own address. You might see:

  • 127.0.0.1 — the loopback address, always present, used for internal communication within the machine
  • 192.168.x.x or 10.x.x.x — a private (local) IP assigned by your router
  • A public IP — assigned by your ISP, not directly visible on the interface in most home setups

Knowing which type of IP you need determines which command and method makes sense.

The Modern Way: Using the ip Command 🖥️

The ip command is the current standard on most Linux distributions, replacing the older ifconfig tool. It's included by default on Debian, Ubuntu, Fedora, Arch, and most modern distros.

To see all network interfaces and their addresses:

ip addr show 

Or the shorthand:

ip a 

This returns a list of every network interface. Look for entries labeled inet (IPv4) or inet6 (IPv6). The interface names vary by system — common ones include:

Interface NameWhat It Typically Represents
loLoopback (127.0.0.1)
eth0 / enp3s0Wired Ethernet
wlan0 / wlp2s0Wireless (Wi-Fi)
docker0 / virbr0Virtual interfaces (containers, VMs)

To check a specific interface only:

ip addr show eth0 

Replace eth0 with the name of your actual interface.

The Older Way: ifconfig

On older systems or distributions that still ship with net-tools, ifconfig remains a familiar option:

ifconfig 

If the command isn't found, it either needs to be installed (sudo apt install net-tools on Debian/Ubuntu) or the system has moved fully to the ip command. The output is similar — look for inet under each interface block.

Finding Only Your Local IP Quickly

If you want a clean, one-line output without scrolling through interface details, these commands filter the result:

hostname -I 

This prints all local IP addresses assigned to the machine, space-separated. It's fast and readable, though it won't tell you which address belongs to which interface.

Another option using ip with output filtering:

ip route get 1.1.1.1 | awk '{print $7; exit}' 

This asks the system which local IP it would use to reach an external address — effectively surfacing the primary outbound IP, which is often what you actually want when configuring services or connections.

Finding Your Public IP Address

Your public IP is assigned by your ISP and is what the outside internet sees. It is not shown by ip addr or ifconfig in standard home and office setups, because most networks use NAT (Network Address Translation) — your router handles the public address, and your Linux machine only sees the private one.

To find your public IP from the command line: 🌐

curl ifconfig.me 

Or alternatives:

curl icanhazip.com curl ipinfo.io/ip 

These query an external service that returns the IP your request appears to come from. This requires an active internet connection and curl installed (available by default or easily installed on most distros).

Variables That Affect What You See

The IP address (or addresses) you find will depend on several factors specific to your setup:

  • Network configuration: DHCP environments assign addresses automatically and they can change. Static configurations hold a fixed address.
  • Number of interfaces: Servers, containers, and machines with VPNs active will show multiple addresses across multiple interfaces.
  • VPN usage: When a VPN is active, a new virtual interface (often tun0 or wg0) appears with its own IP, and your public IP as seen externally changes entirely.
  • IPv4 vs IPv6: Modern systems support both. Commands like ip a show both; some use cases require knowing specifically which version is in use.
  • Distribution and version: Older distributions may not have the ip command; very minimal server installs may lack curl.

When Results Get Complicated

On machines running Docker, VirtualBox, KVM, or similar virtualization tools, the interface list grows significantly. You'll see bridge interfaces, virtual network adapters, and container-specific addresses alongside your actual physical interface. The ip a output on a development machine can easily show five or more interfaces with different addresses.

Similarly, systems connected to multiple networks simultaneously — such as a machine with both wired and wireless connections active — will show valid IPs on each. Which one "matters" depends entirely on what you're trying to do with it.

The right IP address to use isn't always the first one listed, and on complex setups, knowing your specific goal — local communication, external access, container networking, remote SSH — is what determines which address is actually relevant to you.