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
- 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.
- Run the
ip addrcommand. Typeip addrand press Enter. This shows all network interfaces with their IP addresses. Look for lines starting withinet(IPv4) orinet6(IPv6). The address afterinetis your IP, e.g.,192.168.1.10/24. The part before the slash is the IP; the number after is the subnet prefix. - Use
ip -4 addrto see only IPv4 addresses. If the output is long, this filters it to just IPv4. Similarly,ip -6 addrshows only IPv6. - Try the older
ifconfigcommand. On some systems,ifconfigis still available. Runifconfigorifconfig -ato see all interfaces. Look forinet addr:for IPv4. If you get “command not found”, installnet-tools(see Troubleshooting). - 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.meorcurl icanhazip.com. This returns just your public IPv4 address. For IPv6, trycurl -6 ifconfig.me. - Identify which interface is which. Common names:
eth0orenp3s0for wired Ethernet,wlan0orwlp2s0for Wi-Fi,lofor loopback (always 127.0.0.1). The interface with an IP other than 127.0.0.1 is your active connection. - 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 addrshows private IPs;curl ifconfig.meshows the public one. - Mixing up IPv4 and IPv6. IPv6 addresses look like
fe80::1or2001: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
/24in192.168.1.10/24is not part of the IP; it’s the subnet mask in CIDR notation. - Using
ifconfigwithout installing net-tools. Many modern distros don’t include it by default. If you get “command not found”, useip addrinstead.
Tips
- Use
ip -br addrfor 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 routeto 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
ipis 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 iproute2on Debian/Ubuntu). - “ifconfig: command not found” – Install net-tools:
sudo apt install net-tools(Debian/Ubuntu) orsudo dnf install net-tools(Fedora). Or just useip 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—trysudo dhclient eth0. curl ifconfig.mehangs or fails. This usually means no internet connection or a firewall blocking outbound HTTP. Check your connection withping 8.8.8.8. If ping works but curl doesn’t, try a different service likecurl 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
- iOS 18 Safari Not Working? Fixes That Help
- How to Check Your Linux Kernel for Spectre
- iPhone Safe Mode: How to Enable or Disable It
- Fix Slow Internet Lag on Samsung Galaxy Note
- Google Play Protect: How It Secures Your Android
- Fix SFC Scannow Error in Windows: Complete Guide