The fastest way to see your IP address

The quickest command to see your IP address in Linux is hostname -I. Type it into the terminal and press Enter, and you will see all the IP addresses assigned to your machine on one line. This works on most Linux distributions without installing anything extra.

If you want to see more detail — which network interface each address belongs to, whether it is active, and what subnet mask it uses — use ip addr show instead. This command displays every network interface on your system, the IP addresses attached to each one, and their status. It is the modern standard tool that has replaced the older ifconfig command on most current Linux systems.

Key Takeaways

  • hostname -I shows all your IP addresses in a single line and is the fastest way to find them.
  • ip addr show displays detailed information about each network interface, including which addresses belong to which interface.
  • ip route show reveals your default gateway and routing information if you need to troubleshoot network connectivity.
  • The ifconfig command still works on many systems but is considered outdated; use the ip commands instead on newer distributions.

Using the ip command for detailed network information

The ip command is the standard tool in modern Linux for viewing network settings. To see all network interfaces and their addresses, type ip addr show or the shorter version ip a. The output shows each interface (like eth0, wlan0, or lo) with its IP address, subnet mask in CIDR notation, and whether the interface is up or down.

If you only want to see addresses for a specific interface, add the interface name: ip addr show eth0 will display only the information for that interface. This is useful when you have multiple network cards and need to focus on one. The output also includes the MAC address (hardware address) of each interface, which you may need for network configuration or troubleshooting.

Finding your public IP address versus your local IP

The commands above show your local IP address — the address your computer uses on your home or office network. This is usually a private address starting with 192.168, 10, or 172.16. Your public IP address is different; it is the address the rest of the internet sees when you connect to websites or services outside your network.

To find your public IP from the Linux terminal, you can use curl ifconfig.me or curl icanhazip.com. These commands contact a web service that reports back the IP address it sees you connecting from. You will need an internet connection and the curl command installed, but most Linux systems include it by default. The public address changes depending on your internet service provider and whether you are behind a router or firewall.

Using ifconfig on older systems

On older Linux distributions or systems where the ip command is not available, ifconfig still works. Type ifconfig to see all network interfaces, or ifconfig eth0 to see a specific one. The output format is different from the ip command but shows the same essential information: the interface name, IP address, subnet mask, and MAC address.

The ifconfig command is no longer installed by default on many modern distributions like Ubuntu 18.04 and later, Fedora, and Debian. If you type it and get a "command not found" error, use ip addr show instead. However, if you are working on a system where ifconfig is already present, there is no harm in using it — it will give you the same information you need.

Checking your gateway and routing information

Sometimes you need to know more than just your IP address. To see your default gateway (the router or device that sends your traffic to other networks), type ip route show. This displays all the routes your system knows about, with the default route usually listed first. The default gateway is the address listed after "via" on the line that starts with "default".

This information is useful when troubleshooting network problems or configuring your system to reach specific networks. If you cannot reach a server or service, checking your gateway and routes can help you understand whether the problem is with your local network setup or something beyond it. The route command is an older alternative that shows similar information but is less commonly used on modern systems.

Viewing IP settings for a specific network interface

If your Linux machine has multiple network interfaces — for example, both Ethernet and Wi-Fi — you may want to check the settings for just one. Use ip addr show wlan0 to see only your Wi-Fi address, or ip addr show eth0 for Ethernet. Replace the interface name with whichever one you need to check.

You can also use ip link show to see all interfaces and their status (up or down) without showing the IP addresses. This is helpful when you want to know which interfaces are active before checking their addresses. Combining these commands — first checking which interfaces are up, then viewing the addresses on the ones you care about — is a practical workflow when managing a system with many network connections.

Frequently Asked Questions

Why do I see multiple IP addresses when I run hostname -I?

Your system may have multiple network interfaces (Ethernet, Wi-Fi, virtual interfaces, or loopback), and each one can have its own IP address. The hostname -I command shows all of them. To see which address belongs to which interface, use ip addr show instead, which labels each address with its interface name.

What is the difference between 127.0.0.1 and my other IP addresses?

127.0.0.1 is the loopback address, a special address your computer uses to talk to itself. It is not a real network address and does not connect to other machines. Your real IP addresses are the ones on interfaces like eth0 or wlan0. You can ignore the loopback address unless you are running local services that need to communicate with themselves.

Can I change my IP address from the terminal?

Yes, but the method depends on whether your network uses DHCP (automatic addresses) or static configuration. For temporary changes, use sudo ip addr add 192.168.1.50/24 dev eth0, replacing the address and interface name as needed. For permanent changes, you will need to edit your network configuration files, which vary by distribution. Check your system's network configuration documentation for the correct file location.

What if the ip command is not installed on my system?

The ip command comes with the iproute2 package, which is installed by default on nearly all modern Linux distributions. If it is missing, you can install it using your package manager: sudo apt install iproute2 on Debian or Ubuntu, or sudo dnf install iproute2 on Fedora. As a fallback, ifconfig or hostname -I will work on most systems.

How do I find the IP address of another computer on my network?

Use the arp command to see devices that have recently communicated with your machine, or use ping followed by a hostname or address to check if a specific device is reachable. For a full network scan, tools like nmap can discover all active devices, but you will need to install it first. For simple cases, ping hostname will tell you the IP address of a machine if it responds.