Guides
Last updated
October 20, 2025

How to Find Your IP Address in Linux (The Fast & Modern Way)

Nicolas Rios

Table of Contents:

Get your free
IP Geolocation
 API key now
stars rating
4.8 from 1,863 votes
See why the best developers build on Abstract
START FOR FREE
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required

Your Machine's Network Identity 🌐

How to Find Your IP Address in Linux - Abstract API

Every device on a network—whether it’s your laptop, a server, or even your smart TV—has an IP address. Think of it like a phone number: it uniquely identifies your machine so it can communicate with others.

Whether you’re setting up a web server, connecting via SSH, or solving a networking hiccup, one of the first steps is learning your Linux system’s IP.

The challenge? Many older guides still point to the ifconfig command. But in today’s Linux world, ifconfig is deprecated and often missing by default, which creates confusion.

This guide takes a modern-first approach:

Your Machine's Network Identity
Enter an IP address to start
Need inspiration? Try
73.162.0.1
VALIDATE
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Checking
5
Results for
ip address
Country:
TEST
Region:
TEST
City:
TEST
Coordinates:
TEST
Zip code:
TEST
Connection:
TEST
Get free credits, more data, and faster results

Finding Your Private IP Address (The Recommended Way ✅)

Your private IP address is the identifier your device uses inside your local network. You’ll need this, for example, to connect from another computer on the same Wi-Fi via SSH.

The Modern Tool: ip addr

The ip command is today’s standard for inspecting and configuring network settings. 

To view your addresses: 

  • ip addr show

Or the shorter alias:

  • ip a

Understanding the Output

Here’s an example output:

2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000

    link/ether 08:00:27:9e:f3:b7 brd ff:ff:ff:ff:ff:ff

    inet 192.168.1.15/24 brd 192.168.1.255 scope global dynamic enp0s3   # 👈 Private IPv4

    inet6 fe80::a00:27ff:fe9e:f3b7/64 scope link                          # 👈 Local IPv6

👉 Look for the line beginning with inet. That’s your IPv4 address—in this case, 192.168.1.15.

👉 If you see a line with inet6, that’s your IPv6 address.

💡 Tip: IPv4 addresses look like 192.168.x.x while IPv6 addresses are longer and separated by colons (fe80::…).

A Faster Alternative: hostname -I

If you only want the IP without extra details: hostname -I

  • This prints just the address(es), making it perfect when you’re in a hurry.

Finding Your Public IP Address (What the Internet Sees 🌍)

Your private IP is like your apartment number 🏠, while your public IP is like the building’s address 🏢—the identifier the rest of the internet sees.

Most networks share a single public IP (provided by your ISP) for all connected devices.

Using curl or wget

Ask an external service to tell you what it sees:

Or:

Prefer wget?

These commands send a quick request to a minimal web service, which replies with your current public IP.

Another Option: dig

If curl or wget aren’t installed, try:

This uses DNS resolution to reveal your public IP.

💡 Note: Many ISPs assign dynamic public IPs, which change periodically. Unless you pay for a static one, don’t be surprised if this number shifts.

The Legacy Method: Using ifconfig ⚠️

⚠️ Legacy Alert: ifconfig is outdated. It isn’t pre-installed in most modern distributions like Ubuntu 18.04+ or CentOS 7+. Use ip instead. If you still need it, install the net-tools package.

  • ifconfig

Sample output:

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.15  netmask 255.255.255.0  broadcast 192.168.1.255

        inet6 fe80::a00:27ff:fe9e:f3b7  prefixlen 64  scopeid 0x20<link>

        ether 08:00:27:9e:f3:b7  txqueuelen 1000  (Ethernet)

👉 Again, check the inet line for your IPv4 address.

Why does ifconfig still appear in guides? Because it was the standard for decades, and plenty of older documentation hasn’t been updated.

Finding Your Default Gateway (Router’s IP) 🚪

Your default gateway is the “front door” through which your traffic leaves your local network to reach the internet.

Run: ip route | grep default

Example output: default via 192.168.1.1 dev enp0s3 proto dhcp metric 100

👉 The address after via is your router’s IP. In this case, 192.168.1.1.

💡 You might need this address to log into your router’s admin panel or troubleshoot connectivity issues.

Conclusion: Command Your Network 🖥️

You now have a complete toolkit for identifying your Linux machine’s network addresses:

🔹 Private IP: pi a or hostname -I

🔹 Public IP: curl ifconfig.me or dig …

🔹 Gateway IP: ip route

By adopting modern tools like ip, you’ll avoid the pitfalls of legacy commands and ensure your knowledge is aligned with current best practices.

Nicolas Rios

Head of Product at Abstract API

Get your free
IP Geolocation
key now
See why the best developers build on Abstract
get started for free

Related Articles

Get your free
IP Geolocation
key now
stars rating
4.8 from 1,863 votes
See why the best developers build on Abstract
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
No credit card required