Check IP Address in Linux: Terminal Commands, GUI & Config Files Guide

Ever found yourself staring blankly at a terminal wondering "how do I find my IP address in this thing?" Trust me, you're not alone. Last month I was setting up a home server and spent a good 20 minutes fumbling around before remembering the right commands. Checking IP address in Linux isn't rocket science, but there are more ways to do it than there are flavors of Ubuntu.

Why does this matter? Well, your IP address is like your computer's phone number on the network. Need to SSH into your machine? Troubleshoot connectivity? Configure a firewall? All require knowing that magical set of numbers. And here's the kicker - Linux gives you at least half a dozen ways to find it.

Quick Command Cheats for Busy Admins

When you're in a hurry, these are my go-to methods for checking IP address in Linux:

$ ip addr show
$ hostname -I

The ip command is the modern replacement for old-school ifconfig. It shows all interfaces and their IPs in one shot. Personally, I find it cleaner than its predecessor. But if you just want your IPv4 address without fuss, hostname -I (capital i!) spits it out directly.

Here's a dirty little secret: I still use ifconfig out of habit sometimes. It works on most systems but isn't installed by default on newer distros like Ubuntu 22.04. When it fails, that's when I remember I should've used ip instead.

Command Comparison Table

Command Best For Shows IPv6 Pre-installed My Rating
ip addr show Detailed interface info Yes Yes (modern distros) ★★★★★
hostname -I Quick IPv4 only No Yes ★★★★☆
ifconfig Traditionalists Yes No (requires net-tools) ★★★☆☆
nmcli device show NetworkManager systems Yes If NM installed ★★★★☆

Deep Dive: Terminal Methods

Let's get our hands dirty with the terminal methods. This is where Linux shines for checking ip address information.

The Modern ip Command

Run this in your terminal:

$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:16:3e:e2:15:41 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.23/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever

See that inet line under eth0? That's your IPv4 address. The /24 indicates subnet mask (255.255.255.0). What I love about this output is it shows both IPv4 and IPv6 addresses, MAC address, interface status - everything in one place.

Pro Tip: Shorten it with ip -br a for cleaner output:
$ ip -br a
lo      UNKNOWN  127.0.0.1/8 
eth0    UP       192.168.1.23/24 fe80::216:3eff:fee2:1541/64

Old Reliable ifconfig

Ah, ifconfig. We've had a love-hate relationship for years. It's like that old car that eventually starts but you're never quite sure when it'll fail. To check IP address in Linux with ifconfig:

$ sudo apt install net-tools  # First install it on Debian/Ubuntu
$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.23  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::216:3eff:fee2:1541  prefixlen 64  scopeid 0x20<link>
        ether 00:16:3e:e2:15:41  txqueuelen 1000  (Ethernet)
        RX packets 1027893  bytes 1393365820 (1.3 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 908587  bytes 188635365 (188.6 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Honestly? I only use this when working on legacy systems. The output is messier than ip and it hasn't been updated for new network features. But hey, if it ain't broke... until your distro removes it.

When You Need External IP Address

Important distinction: your private IP (like 192.168.x.x) isn't what the internet sees. For that, you need your public IP. Here's my favorite trick:

$ curl ifconfig.me

Or if you prefer:

Command Response Time Extra Info
curl icanhazip.com Fast Pure IP only
curl ifconfig.me Medium Shows IPv6 with -6 flag
curl ipinfo.io/ip Slow Full details at ipinfo.io

Fun story: Last year I was debugging a firewall issue and spent hours checking configurations. Turns out I was looking at the wrong IP because I forgot my VPN was active. Now I always double-check public IP when debugging external access issues.

GUI Methods (For Terminal Haters)

Not everyone loves terminals. Here's how to check Linux IP address graphically:

  • Ubuntu/Debian: Settings → Network → Gear icon
  • Fedora/GNOME: Top-right network icon → Wired Settings
  • KDE Plasma: System Settings → Network → Connections

But here's the real talk: I've seen GUI network managers freeze or show outdated info more times than I can count. Just last week, my Ubuntu machine showed "disconnected" in GUI while actually having perfect connectivity. Terminal commands don't lie.

Network Manager CLI

This sweet spot between GUI and raw commands:

$ nmcli device show eth0 | grep IP4.ADDRESS
IP4.ADDRESS[1]:     192.168.1.23/24

Extremely reliable on systems using NetworkManager (most desktop distros). Shows additional useful details like DHCP lease info and DNS servers.

Permanent Config Files

Where does Linux actually store IP addresses? Depends on your distro:

Distribution Primary Config File Backup Locations
Debian/Ubuntu /etc/network/interfaces /etc/netplan/*.yaml
RHEL/CentOS 7 /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network
RHEL/CentOS 8+ /etc/NetworkManager/system-connections/ /etc/sysconfig/network-scripts/
Arch/Manjaro /etc/netctl/ systemd-networkd files
Heads up: Editing these directly can break network connectivity! Always backup first. I learned this the hard way when I locked myself out of a remote server.

Example Static IP Setup (Ubuntu)

Say you want to set a static IP instead of DHCP. Here's what /etc/netplan/01-netcfg.yaml might look like:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses: [192.168.1.100/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 1.1.1.1]

Apply with:

$ sudo netplan apply

Took me three server rebuilds to memorize that syntax. Save yourself the pain.

Expert Tools & Diagnostic Commands

Beyond basic checking ip address in Linux, these are golden for troubleshooting:

  • ss -tuln - Show open ports (better than netstat)
  • ip route show - View routing table
  • nmap -sn 192.168.1.0/24 - Discover devices on network
  • arp -a - Show MAC address tables

My networking toolkit always includes Wireshark for deep packet inspection and mtr for real-time traceroutes. Worth installing even if you only use them once a year.

Network Manager Diagnostic

This saved me during a weird DNS issue:

$ nmcli general logging level DEBUG domains ALL
$ journalctl -f -u NetworkManager

Shows real-time debug logs. Warning: extremely verbose! But when you're stuck, it's priceless.

FAQs: Real Questions from Linux Users

Why don't I see my IP address when checking?

Common causes: - Interface down (fix: sudo ip link set eth0 up) - No DHCP response (check router) - Wrong network cable (yes, really) - Driver issues (lspci -k to check)

Happened to me on a cheap USB Ethernet adapter. Driver was missing - had to compile from source.

Static vs Dynamic IP: Which should I use?

Dynamic (DHCP): - ✅ Easy setup - ✅ No conflicts - ❌ Address can change

Static: - ✅ Consistent address - ✅ Better for servers - ❌ Manual config - ❌ Potential conflicts

I use static for servers/devices I access frequently (NAS, printers), DHCP for everything else.

How to check Linux IP address from another machine?

Two methods: 1. Scan network: nmap -sn 192.168.1.0/24 2. Check router: Log into your router's DHCP client list

Better yet: set hostnames with avahi-daemon so devices appear as mypc.local instead of IP.

IPv6 address confusing me!

IPv6 addresses look scary (fe80::216:3eff:fee2:1541). Key things:

  • :: means all zeros in between
  • fe80 prefix = link-local (not routable)
  • Use ip -6 addr to show only IPv6

Took me months to get comfortable with them. Stick with it - they're the future.

Final Recommendations

After years of managing Linux systems, here's my workflow:

  1. Quick check: hostname -I for immediate IPv4 need
  2. Detailed analysis: ip addr show
  3. Public IP: curl icanhazip.com
  4. Troubleshooting: ip route + ss -tuln

Essential packages to install: - iproute2 (always installed) - net-tools (for ifconfig) - nmap (network scanning) - bind-utils (dig, nslookup)

Avoid getting stuck like I did - bookmark a few IP checking commands. Seriously, print them and tape to your monitor if needed. Nothing worse being locked out of your own server because you forgot how to check its IP address.

Different methods work for different Linux environments, but whether you're on Debian, checking IP address in Ubuntu, or wrestling with CentOS, the fundamentals remain the same. Master these commands and you'll save yourself countless hours of network headaches.

Leave a Comments

Recommended Article