sodcalculator

10 Tech How-To

How to Check IP Address in Linux

Guide 10-46337 · Updated · Step by step

This guide shows you how to find the IP address of your Linux machine using both the command line and graphical tools. You’ll learn commands for viewing IPv4 and IPv6 addresses, identifying which interface is which, and checking your public IP. No special software is needed—everything uses built-in Linux utilities.

What You’ll Need

  • A Linux system with a terminal (most distributions include one by default).
  • Basic familiarity with opening a terminal window (Ctrl+Alt+T on many systems).
  • For checking the public IP, an internet connection.

Step-by-Step

  1. Open a terminal. Look for “Terminal”, “Konsole”, “GNOME Terminal”, or “xterm” in your applications menu. You can also press Ctrl+Alt+T on most desktop environments.
  2. Run the ip addr command. Type ip addr and press Enter. This shows all network interfaces with their IP addresses. Look for lines starting with inet (IPv4) or inet6 (IPv6). The address after inet is your IP, e.g., 192.168.1.10/24. The part before the slash is the IP; the number after is the subnet prefix.
  3. Use ip -4 addr to see only IPv4 addresses. If the output is long, this filters it to just IPv4. Similarly, ip -6 addr shows only IPv6.
  4. Try the older ifconfig command. On some systems, ifconfig is still available. Run ifconfig or ifconfig -a to see all interfaces. Look for inet addr: for IPv4. If you get “command not found”, install net-tools (see Troubleshooting).
  5. Check your public IP address. To see the IP your internet service provider assigns you, use a web-based service from the terminal. Run curl ifconfig.me or curl icanhazip.com. This returns just your public IPv4 address. For IPv6, try curl -6 ifconfig.me.
  6. Identify which interface is which. Common names: eth0 or enp3s0 for wired Ethernet, wlan0 or wlp2s0 for Wi-Fi, lo for loopback (always 127.0.0.1). The interface with an IP other than 127.0.0.1 is your active connection.
  7. Use the hostname command (alternative). Run hostname -I (capital I) to get a space-separated list of all IP addresses assigned to your machine. This is quick and easy but doesn’t show interface names.

Common Mistakes

  • Confusing private and public IPs. Private IPs (like 192.168.x.x, 10.x.x.x, 172.16.x.x) are used on your local network. The public IP is what the rest of the internet sees. ip addr shows private IPs; curl ifconfig.me shows the public one.
  • Mixing up IPv4 and IPv6. IPv6 addresses look like fe80::1 or 2001:db8::1. They are longer and use colons. Make sure you’re looking at the right type.
  • Reading the subnet prefix as part of the IP. The /24 in 192.168.1.10/24 is not part of the IP; it’s the subnet mask in CIDR notation.
  • Using ifconfig without installing net-tools. Many modern distros don’t include it by default. If you get “command not found”, use ip addr instead.

Tips

  • Use ip -br addr for a compact view. This gives a “brief” output showing interface names and IPs in a single line each, which is easier to scan.
  • Watch for multiple IPs. A machine can have several IPs (e.g., Docker containers, VPNs). The one on your main interface (eth0/wlan0) is your primary.
  • Check your default gateway. Run ip route to see the gateway IP (usually your router). This is useful for network troubleshooting.
  • For a GUI alternative, most desktop environments show the IP in the network settings. Click the network icon in the system tray and look for “Connection Information” or similar.

Troubleshooting

  • “ip: command not found” – This is rare because ip is part of iproute2, installed by default on almost all distros. If you see it, install iproute2 using your package manager (e.g., sudo apt install iproute2 on Debian/Ubuntu).
  • “ifconfig: command not found” – Install net-tools: sudo apt install net-tools (Debian/Ubuntu) or sudo dnf install net-tools (Fedora). Or just use ip addr.
  • No IP address shown for your interface. This means the interface is down or not connected. Check the cable/Wi-Fi. To bring it up, run sudo ip link set eth0 up (replace eth0 with your interface). If it still doesn’t get an IP, your DHCP might be failing—try sudo dhclient eth0.
  • curl ifconfig.me hangs or fails. This usually means no internet connection or a firewall blocking outbound HTTP. Check your connection with ping 8.8.8.8. If ping works but curl doesn’t, try a different service like curl ipinfo.io/ip.
  • You see a 169.254.x.x address. This is an Automatic Private IP Address (APIPA) assigned when DHCP fails. Check your router and cable, then restart your network interface.

Frequently Asked Questions

What is the difference between ip addr and ifconfig?

ip addr is the modern command from the iproute2 suite, more powerful and recommended. ifconfig is older and deprecated but still works on systems with net-tools installed. The output format differs slightly, but both show IP addresses.

How do I find my IP address without using the terminal?

Most desktop environments have a GUI. Click the network icon in the system tray (top-right on GNOME, bottom-right on KDE) and select “Settings” or “Connection Information”. You’ll see the IPv4 and IPv6 addresses.

Why does my IP address keep changing?

Your router likely uses DHCP, which assigns IPs dynamically. To get a static IP, configure your network settings in the GUI or edit the netplan/NetworkManager configuration files. This is beyond the scope of this guide, but the files are usually in /etc/netplan/ or /etc/NetworkManager/.

Can I see the IP address of another device on my network?

Yes, you can scan your local network. Use arp -a to see the ARP table, or install a tool like nmap and run sudo nmap -sn 192.168.1.0/24 (replace with your subnet). This shows all active devices and their IPs.

What is the loopback address?

The loopback interface (lo) always has the IP 127.0.0.1. It’s used for the machine to communicate with itself, for testing services, and for local development. It’s not your real IP.

How do I find my public IP if I’m behind a router?

Your router performs NAT, so your machine’s private IP is different from the public IP. The only way to see your public IP is to query an external service like curl ifconfig.me or visit a website like whatismyip.com in your browser.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →