How to Find 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 setting up a server, troubleshooting a connection, or configuring remote access. The good news is that Linux gives you multiple ways to find this information, each suited to slightly different situations and skill levels.
What "IP Address" Actually Means in This Context
Before running any commands, it's worth being clear about which IP address you're looking for — because your Linux system likely has more than one.
- Private (local) IP address — the address assigned to your machine on your local network (home, office, or data center LAN). This is what other devices on the same network use to reach you.
- Public (external) IP address — the address the wider internet sees when your traffic leaves your router. This is assigned by your ISP, not your machine.
- Loopback address — always
127.0.0.1, used internally by the system itself. Not useful for networking with other devices.
Most Linux commands show you the private IP address. Getting your public IP requires a different approach.
The Modern Way: Using ip addr 🖥️
The ip command is the current standard tool for network configuration on Linux. It replaced the older ifconfig command on most modern distributions (Ubuntu 18.04+, Fedora, Debian 10+, etc.).
To display all network interfaces and their assigned addresses:
ip addr Or the shorthand:
ip a What you'll see: A list of network interfaces. Look for entries like eth0, ens33, wlan0, or enp3s0 — these represent your physical or virtual network adapters. Under each, find the line starting with inet followed by an IPv4 address (e.g., 192.168.1.45/24), or inet6 for IPv6.
To filter output to just IPv4 addresses:
ip -4 addr show To check a specific interface only:
ip addr show eth0 The Older Way: ifconfig
On older Linux systems — or if you've installed the net-tools package manually — ifconfig still works:
ifconfig The layout is different from ip addr, but you're still looking for the inet value next to your active interface. If ifconfig returns a "command not found" error on your system, your distribution has likely dropped it by default. Install with:
sudo apt install net-tools # Debian/Ubuntu sudo dnf install net-tools # Fedora/RHEL Quick One-Liner Options
If you want just the IP address without parsing through full output, these targeted commands help:
Show only private IPs with hostname:
hostname -I This returns all IP addresses assigned to the machine, space-separated, with no extra noise. It's the fastest option for scripting or quick checks.
Using ip with grep:
ip addr | grep 'inet ' | grep -v '127.0.0.1' This strips out the loopback address and shows only your real network addresses.
Finding Your Public IP Address 🌐
Your public IP isn't stored on your machine — it's assigned at the router/ISP level. To retrieve it from the command line:
curl ifconfig.me Or alternatives like:
curl icanhazip.com curl api.ipify.org These send a request to an external service that echoes back the IP your traffic originated from. This requires an active internet connection. The result may differ from your private IP by a significant margin — that's normal and expected when you're behind NAT (Network Address Translation).
Comparing Methods at a Glance
| Method | Command | Shows | Requires Internet |
|---|---|---|---|
| Modern standard | ip addr | Private IP(s) | No |
| Legacy tool | ifconfig | Private IP(s) | No |
| Quick hostname lookup | hostname -I | Private IP(s) | No |
| Public IP via curl | curl ifconfig.me | Public IP | Yes |
Variables That Affect What You'll See
The output you get — and which method works on your system — depends on several factors:
Distribution and version — ip is standard on systemd-based distros; older or minimal installs may only have ifconfig or neither by default.
Number of network interfaces — servers and VMs often have multiple interfaces (ethernet, loopback, virtual bridges, VPN tunnels). Each gets its own IP. Running a Docker host, for example, will show bridge interfaces like docker0 alongside your main adapter.
IPv4 vs IPv6 — modern Linux systems often show both. Some environments (especially cloud instances) may be IPv6-primary. The inet line is IPv4; inet6 is IPv6.
DHCP vs static assignment — on DHCP, your private IP can change between network sessions unless a reservation is set. On static configurations, it stays fixed. This matters if you're troubleshooting why a previously-working address stopped working.
Cloud and container environments — on AWS EC2, GCP, or Azure instances, the private IP shown by ip addr is the instance's internal address. The public IP is assigned at the cloud platform level and may only be visible via instance metadata services or external lookup.
What Determines Which Method Is Right for You
A developer SSHing into a remote server needs something different than a sysadmin configuring a local VM, a desktop user checking their home network connection, or someone writing a Bash script that needs to self-report an IP dynamically. The commands themselves are straightforward — what varies is which IP matters, on which interface, in which context. Your network topology and what you're actually trying to accomplish with the address are the pieces only you can assess.