Finding your IP address in Linux
Your IP address is the number that identifies your computer on a network. Linux gives you several straightforward ways to find it, and the method you choose depends on what you're working with — whether you need the address for your local network, your internet connection, or a specific network device.
The fastest way is to open a terminal and run a single command. Most Linux users will get what they need in under a minute using either ip or ifconfig, depending on which version of Linux you're running.
Key Takeaways
- The ip addr command works on all modern Linux systems and shows your IP address alongside your network device name.
- The ifconfig command is older but still available on many systems and displays similar information in a different format.
- Your local network IP usually starts with 192.168, 10.0, or 172.16, while your internet-facing IP is what websites see when you connect.
- The hostname -I command gives you just the IP address with no extra information, useful when you need the number quickly.
- If you're connected through a virtual machine or container, you may have multiple IP addresses, and the right one depends on what you're trying to do.
Using the ip command to see all network addresses
The ip command is the standard tool on modern Linux systems. Open your terminal and type this:
ip addr
The output will show every network device on your computer, along with its IP address. You'll see something like "inet 192.168.1.45/24" — that number before the slash is your IP address. If you have multiple network devices (ethernet, WiFi, virtual devices), each one will appear as a separate block with its own address.
If the output is long and hard to read, you can narrow it down to just one device. For example, to see only your WiFi connection, type:
ip addr show wlan0
Replace "wlan0" with "eth0" if you're using a wired connection, or check the full output of ip addr first to see what your device is actually called.
Using ifconfig for older Linux systems
If ip addr doesn't work or you're on an older Linux system, try ifconfig. Type this in your terminal:
ifconfig
This shows the same information as ip addr but in a different layout. Look for the line that says "inet" followed by a number — that's your IP address. It will be formatted like "inet 192.168.1.45" without the slash and subnet mask that ip addr shows.
Like ip addr, you can view a single device by typing ifconfig wlan0 or ifconfig eth0. On some systems, ifconfig may not be installed by default, in which case the ip command is your better choice.
Getting just the IP address with hostname
If you only need the IP address itself without all the extra network information, use the hostname command:
hostname -I
This prints just the IP address or addresses, nothing else. It's useful when you're writing a script or when you need to copy the address quickly. If you have multiple network devices active, this command will show all their addresses separated by spaces.
Note that this command shows your local network addresses. If you need your internet-facing IP (the one websites see), this won't give it to you — you'll need to use one of the other methods and look for an address that doesn't start with 192.168, 10.0, or 172.16.
Understanding local versus internet IP addresses
When you run these commands, you may see more than one IP address. Your local network IP is the one your router assigned to your computer — it usually starts with 192.168, 10.0, or 172.16. This is the address other devices on your home or office network use to reach you.
Your internet-facing IP is different. It's assigned by your internet service provider and is what websites see when you connect to them. You won't see this address in ip addr or ifconfig unless you're running a server that connects directly to the internet. If you need to know your internet IP, you'll have to check it through a website or use a different method.
If you're behind a router (which most home users are), your local IP and your internet IP are completely different numbers. This is normal and expected.
Finding IP addresses for specific network devices
If you have multiple network devices and need to find the IP for a particular one, first run ip addr or ifconfig to see all devices and their names. Common device names include eth0 or eth1 for wired connections, wlan0 or wlan1 for WiFi, and docker0 or veth for virtual devices.
Once you know the device name, you can view just that one by typing ip addr show devicename or ifconfig devicename. This is especially useful if you're running virtual machines or containers and need to track which IP belongs to which system.
If a device doesn't have an IP address yet, you'll see "inet" missing from its output entirely. This usually means the device isn't connected or hasn't been assigned an address by your network. You can assign one manually using ip addr add, but that's a separate task beyond finding an existing address.
Troubleshooting when commands don't work
If ip addr returns "command not found", your system may be very old or minimal. Try ifconfig instead. If that also fails, you can check the file /etc/hosts or look in your network configuration files, though this is less reliable than using the commands.
If you run the commands but see no IP address (only "inet" lines with "127.0.0.1"), your network device may not be connected or configured. Check that your ethernet cable is plugged in or that you're connected to WiFi. You can also try restarting your network with sudo systemctl restart networking, though this requires administrator access.
If you're inside a virtual machine or container, the IP address you see may be internal to that environment only. The host computer (the physical machine running the virtual one) will have its own separate IP address. Check which system you're actually logged into before assuming the address you found is the one you need.
Frequently Asked Questions
What's the difference between 127.0.0.1 and my actual IP address?
127.0.0.1 is your computer talking to itself — it's called localhost. Your actual IP address is what other devices use to reach you. If you only see 127.0.0.1, your network device isn't connected or configured yet. Check your ethernet cable or WiFi connection and try the commands again.
Why do I see multiple IP addresses when I run ip addr?
Each network device on your computer gets its own IP address. If you have WiFi and ethernet both active, you'll see two addresses. Virtual machines, containers, and VPN connections also create additional devices. You only need to use the one that matches what you're trying to do — usually your WiFi or ethernet address.
Can I change my IP address from the command line?
Yes, but it requires administrator access and knowledge of your network setup. Use sudo ip addr add to add a new address or edit your network configuration files. Most users should leave this to their network administrator or system setup, since a wrong change can disconnect you from the network.
How do I find the IP address of another computer on my network?
Use the ping or arp command to find other devices. For example, ping computername will show you another computer's IP if it's on the same network. This is different from finding your own IP address, which is what the commands in this guide do.
Is my IP address the same every time I restart?
Usually yes for local network addresses — your router typically assigns the same IP to the same device each time. However, this isn't may provide. If you need a permanent address, you can set a static IP in your network settings or ask your router to reserve one for your device.