Search Authority

Check IP Address on Linux: Quick & Easy Guide

Finding your machine IP address on Linux is essential for troubleshooting network issues, setting up services, or securing server access. This guide shows the exact commands and...

Mara Ellison Jul 25, 2026
Check IP Address on Linux: Quick & Easy Guide

Finding your machine IP address on Linux is essential for troubleshooting network issues, setting up services, or securing server access. This guide shows the exact commands and scenarios where each approach shines.

Whether you are working on a local development box or managing cloud instances, knowing how to check IP address on Linux helps you diagnose connectivity problems quickly and keep workflows moving smoothly.

Command Use Case Level of Detail Availability
ip addr Quick overview of all interfaces Brief with interface names and CIDR iproute2 (default on most distros)
hostname -I List all active non-loopback addresses Concise, one-line output Util-linux (minimal dependencies)
ifconfig Traditional detailed per-interface view Hardware, traffic stats, and addressing Requires net-tools package on newer systems
nmcli device show NetworkManager managed environments Properties, IP, DNS, and device state NetworkManager CLI (desktop and many servers)
cat /proc/net/fib_trie Kernel routing table address details Host-local and broadcast scopes Available on all Linux kernels

Using ip addr to check IP address on Linux

The ip command from the iproute2 package is the modern replacement for ifconfig and is present by default on most distributions. Running ip addr or ip a shows each network interface with its link state, MAC address, and assigned IP prefixes in both IPv4 and IPv6.

You can narrow the output to a specific device by appending dev interface, which is useful on servers with many NICs or bonds. This approach is ideal for scripting because the column aligned output can be parsed reliably with standard text tools like awk and grep.

For quick human reading, ip -br addr provides a concise table with interface names, state flags, and addresses, making it straightforward to confirm whether an interface has received the expected DHCP or static assignment.

Discovering IP with hostname and resolvectl

The hostname -I command prints all active IPv4 and IPv6 addresses assigned to non-loopback interfaces, stripping interface names and focusing only on routable or externally visible addresses. This pattern is commonly used in deployment scripts where you need to capture the primary IP into a variable without extra cleanup.

On systems managed by systemd, resolvectl can also expose DNS and link information, and resolvectl query shows how a hostname resolves while indicating the IP address used for outbound communication. Combine this with standard networking tools when you need to correlate DNS, firewall rules, and the actual endpoint address seen by remote services.

These commands are lightweight and fast, which makes them suitable for inclusion in health checks, startup probes, and simple diagnostic workflows where you want minimal overhead and maximum compatibility.

Traditional ifconfig approach

If your environment still relies on ifconfig, you can install the net-tools package on distributions that have moved exclusively to iproute2. The ifconfig command displays detailed per-interface information, including broadcast addresses, netmasks, and packet counters, which some legacy tools still reference.

While ifconfig is being phased out in favor of ip, it remains useful in older documentation and scripts, and it can provide a mental bridge when working with seasoned administrators who learned networking through classic Unix tools. Use ifconfig only when ip or hostname produce output that is difficult to map to your existing processes.

NetworkManager and nmcli workflows

On desktops and cloud images that use NetworkManager, nmcli device offers a structured way to query device status, IP configuration, and routing rules. You can retrieve the current IP address, gateway, and DNS settings in a single command, which is especially helpful in headless or containerized environments where predictable network profiles matter.

nmcli connection show active-connection can reveal which connection profile is active and which interface it binds to, allowing you to cross-check IP assignments against the intended configuration. This visibility is valuable when you are debugging policy-based routing, VLAN tagging, or team bonding setups that may not be reflected by simple ip addr output.

Key recommendations for Linux networking

  • Use ip addr or hostname -I for quick, script-friendly checks of assigned addresses.
  • Prefer iproute2 tools over legacy ifconfig for new automation and monitoring tasks.
  • Validate interface names and states with ip -br addr before launching dependent services.
  • In NetworkManager environments, verify active profiles with nmcli to ensure correct IP configuration.
  • For public-facing diagnostics, use curl with a trusted external IP echo service while considering privacy and network policies.

FAQ

Reader questions

How can I find only my primary IPv4 address without extra details?

Use hostname -I to list all non-loopback IPv4 addresses in a simple one-line format, or pipe ip -4 addr through awk to extract just the address associated with your main interface.

What command shows IP address and interface status together on Linux?

Run ip -br addr to see a table with interface names, state flags like UP or DOWN, and assigned IPv4 and IPv6 addresses in a human-friendly layout.

Why does ifconfig not show my IP address on newer systems?

ifconfig is often missing by default because net-tools is deprecated on many distributions, so you need to install the package or switch to the ip command from iproute2.

Can I retrieve the external IP address from the command line on Linux?

Yes, query a reliable web service such as curl ifconfig.me or similar endpoints with tools like curl or wget, but prefer trusted sources and be aware of rate limits in automated scripts.

Related Reading

More pages in this topic cluster.

How to Tell the Difference Between Silver and Aluminum (Silver vs Aluminum)

Spotting the difference between silver and aluminum helps you verify purchases, appraise items, and avoid overpaying for misidentified metals. While they look similar at first g...

Read next
Excel Keyboard Shortcut for Strikethrough: Easy Step-by-Step Guide

Mastering the Excel keyboard shortcut for strikethrough helps you track completed tasks, revisions, and action items without leaving the keyboard. This small efficiency habit sp...

Read next
Durham NC News Today: Latest Headlines & Updates

Durham NC news keeps the Research Triangle region informed about breakthrough healthcare, education, and downtown development. Local reporting connects residents and visitors to...

Read next