How to Check Your IP Address in Linux

Knowing your IP address in Linux is one of those fundamental networking tasks that comes up constantly — whether you're configuring a server, troubleshooting connectivity, setting up SSH access, or just curious about your network setup. Linux gives you several ways to find this information, and the right method depends on your distro, your environment, and exactly what you're looking for.

What "IP Address" Actually Means in This Context

Before diving into commands, it helps to understand that Linux systems can have multiple IP addresses — sometimes several at once. There are two distinct types you may need:

  • Private (local) IP address — the address assigned to your machine within your local network (e.g., 192.168.1.x or 10.0.0.x). This is what your router sees.
  • Public (external) IP address — the address your internet traffic appears to come from. This is assigned by your ISP and shared across your entire network unless you have a dedicated IP.

Most Linux networking commands show you private addresses. Getting your public IP requires a different approach.

The Modern Way: Using the ip Command

The ip command is the current standard on most Linux distributions. It replaced the older ifconfig tool and is available by default on virtually all modern systems running iproute2.

To display all network interfaces and their assigned addresses:

ip addr show 

Or the shorthand:

ip a 

This outputs a list of all network interfaces. You'll typically see:

  • lo — the loopback interface (always 127.0.0.1, used internally)
  • eth0 or ens3 — a wired Ethernet interface
  • wlan0 or wlp2s0 — a wireless interface

Your IPv4 address appears after the inet label. Your IPv6 address, if assigned, appears after inet6.

To check a specific interface only:

ip addr show eth0 

Replace eth0 with your actual interface name.

The Older Way: ifconfig

On older Linux systems — or distributions where net-tools is still installed — ifconfig remains usable:

ifconfig 

If the command isn't found, you can install it:

sudo apt install net-tools # Debian/Ubuntu sudo yum install net-tools # RHEL/CentOS 

The output format differs from ip addr, but the key fields are the same: look for inet addr (IPv4) and inet6 addr (IPv6) under each interface.

Checking Your Public IP Address 🌐

None of the terminal commands above will show your public-facing IP. For that, you need to query an external service. Several command-line methods work well:

curl ifconfig.me 
curl icanhazip.com 
curl ipinfo.io/ip 

Each of these sends a request to a web service that reflects back the IP address it sees your connection coming from. Any one of them works — they all return a plain-text IP address in the terminal.

If curl isn't installed, wget is a common alternative:

wget -qO- ifconfig.me 

Filtering Output for Cleaner Results

The full output of ip addr can be verbose. If you just want the IPv4 address for a specific interface, you can filter with grep:

ip addr show eth0 | grep "inet " 

For a single clean line showing only the address:

ip -4 addr show eth0 | grep -oP '(?<=inets)d+(.d+){3}' 

This kind of filtering is useful in shell scripts where you need to capture the IP dynamically.

Checking IP in Different Linux Environments

The method that works best varies depending on your setup:

EnvironmentRecommended Method
Desktop Linux (Ubuntu, Fedora, etc.)ip a or GUI network settings
Headless server / VPSip addr show via SSH
Docker containerip a or hostname -I
WSL (Windows Subsystem for Linux)ip a (shows WSL virtual adapter)
Minimal/embedded Linuxhostname -I (lightweight, no extras needed)

hostname -I is worth highlighting separately — it's a fast, minimal command that prints all assigned IP addresses with no extra formatting:

hostname -I 

It won't show interface names or IPv6 details by default, but for a quick check it's hard to beat.

IPv4 vs. IPv6 — What You're Actually Seeing

Modern Linux systems are often assigned both an IPv4 and an IPv6 address on the same interface. In ip addr output:

  • Lines starting with inet show IPv4 addresses
  • Lines starting with inet6 show IPv6 addresses

To explicitly filter by protocol version:

ip -4 addr # IPv4 only ip -6 addr # IPv6 only 

If your system shows a link-local IPv6 address starting with fe80::, that's automatically assigned and only valid within your local network segment — it's not a globally routable address.

What Affects Which Address You See

Several variables influence what IP address your Linux system holds at any given time:

  • DHCP vs. static assignment — Most home and office setups use DHCP, meaning your router assigns an address that can change. Servers typically use static addresses.
  • Network manager in useNetworkManager, systemd-networkd, and manual ifupdown configurations can all behave differently.
  • Virtual machines and containers — These add virtual network interfaces with their own addresses, separate from the host.
  • VPN connections — An active VPN adds a new interface (often tun0 or wg0) with its own IP, and may change what your public IP appears to be.
  • Multiple network adapters — A machine with both wired and wireless connections active will show different IPs on each interface.

Which address actually matters to you — and which command surfaces it most cleanly — comes down to what your specific environment looks like and what you're trying to accomplish with that information. 🖥️