The three commands that show your IP address

On Linux, you can find your IP address using the command line. The most straightforward method is to open a terminal and type hostname -I, then press Enter. This displays all IP addresses assigned to your computer on one line.

If you want more detail about which address belongs to which network connection, use ip addr show instead. This lists every network interface on your machine — ethernet, WiFi, virtual connections — along with its IP address, subnet mask, and status. The address you see next to "inet" is your IPv4 address; "inet6" is your IPv6 address if your network supports it.

A third option is ifconfig, an older command that still works on most systems. Type it and look for "inet addr:" to find your IPv4 address. Some newer Linux distributions have removed this command, so if it does not work, use ip addr show instead.

Key Takeaways

  • Type hostname -I in a terminal to see all your IP addresses in one quick line.
  • Use ip addr show to see which IP address belongs to which network connection (WiFi, ethernet, etc.).
  • Your IPv4 address is the one you need to share with other devices on your home network; it usually starts with 192.168 or 10.
  • If you need to find a specific device's address on your network, use arp -a to see all devices your computer has recently talked to.

Understanding what the output means

When you run ip addr show, you will see sections labeled with numbers like "1: lo:", "2: eth0:", or "3: wlan0:". The number is just an identifier. The name tells you what type of connection it is: "lo" is your loopback (your computer talking to itself), "eth0" or "enp" names are wired ethernet, and "wlan0" or "wlp" names are WiFi.

Under each connection name, you will see a line starting with "inet" followed by an address like 192.168.1.45/24. The part before the slash (192.168.1.45) is your actual IP address. The number after the slash (24) is the subnet mask in shorthand — it tells your computer which other addresses are on the same local network.

If you see "DOWN" next to a connection name, that interface is not currently active. If you see "UP", the connection is working. This matters because you only need the IP address of connections that are actually in use.

Finding the IP address of a specific network connection

If your computer has multiple network connections and you only want to see one, you can ask for it by name. Type ip addr show eth0 (or replace eth0 with wlan0, enp3s0, or whatever your connection is called) to see only that interface.

You can also use ip -4 addr show to see only IPv4 addresses, or ip -6 addr show to see only IPv6 addresses. This is useful if you know you need one type and want to cut through the noise.

If you are not sure what your connections are called, run ip link show to get a list of all network interfaces with their names and status. Then use that name in the command above.

Why you might need to know your IP address

Your IP address is how other devices find you on your home network. If you want to access your computer remotely from another device on the same WiFi, you need its IP address. If you are setting up a printer or security camera, you often need to type your computer's IP address into a web browser to reach its settings page.

You also need your IP address if you are troubleshooting a network problem. Your internet service provider or a tech support person might ask "what is your IP address?" to understand where the problem is happening. Knowing how to find it quickly saves time.

Some people also use their IP address to set up a static address — one that does not change every time they restart. If your router keeps assigning you a different address and it is causing problems, you can reserve a specific address for your computer so it stays the same.

The difference between your local IP and your public IP

The address you find with hostname -I or ip addr show is your local IP address — the one your router uses to talk to you inside your home. It usually starts with 192.168, 10, or 172.16. This address only works on your home network; the outside internet cannot reach it directly.

Your public IP address is different. It is assigned by your internet service provider and is how the outside world sees your home network. If you need to find your public IP, you cannot use the commands above. Instead, you can visit a website like whatismyipaddress.com from any web browser, and it will show you the address that the internet sees.

This distinction matters for security. Your local IP is safe to share with people on your home network. Your public IP is more sensitive — it can be used to locate your home geographically and to target attacks at your internet connection. You should not share your public IP with strangers online.

Checking if your IP address changed

Most home networks use DHCP, which means your router automatically assigns you an IP address when you connect. This address can change if you restart your computer or your router. If you need to know whether your address has changed, run hostname -I now and write down the result, then restart and run it again.

If the address is different and it is causing problems — for example, a device cannot find your computer anymore — you have two options. You can ask your router to give you the same address every time (called a DHCP reservation), or you can set a static IP address on your computer itself. Both require logging into your router's settings, which is usually done by typing 192.168.1.1 or 192.168.0.1 into a web browser.

If you are not comfortable changing router settings, the simpler approach is to just run hostname -I whenever you need your address. It takes two seconds and always gives you the current one.

Frequently Asked Questions

What if hostname -I does not work on my Linux system?

Try ip addr show instead — it works on all modern Linux distributions. If that does not work either, your system may not have networking set up yet. Check that your network cable is plugged in or that you are connected to WiFi, then try again.

Can I see the IP addresses of other devices on my network?

Yes. Type arp -a to see a list of devices your computer has recently communicated with, along with their IP addresses and MAC addresses. This shows devices on your local network only, not devices on the internet.

Is it safe to share my local IP address with someone?

Yes, your local IP address is safe to share with people on your home network or people you trust. It only works inside your home network anyway. Never share your public IP address with strangers online.

Why do I see multiple IP addresses when I run these commands?

You are seeing one address for each active network connection. Most computers have at least a loopback address (127.0.0.1) for the system to talk to itself, plus one address for your actual network connection. Virtual machines or Docker containers add more.

How do I set a static IP address so it does not change?

You can configure this in your router by reserving an address for your computer's MAC address, or you can set it on the computer itself by editing your network configuration file. The exact steps depend on your Linux distribution and whether you use DHCP or static addressing. Check your distribution's documentation for the specific file to edit.