Whether you are configuring a web server, setting up SSH access, or troubleshooting a network connection, knowing how to check IP address in Ubuntu is a fundamental skill.
There are two types of IP addresses you usually need to find:
- Private IP (LAN): Used within your home or office network (e.g.,
192.168.x.x). - Public IP (WAN): How the outside internet sees your device.
Here is a quick summary of the most effective commands to check IP address in Ubuntu.
Table of Contents
Quick Summary: IP Address Commands
| Command | Syntax | Best Used For | Output Type |
|---|---|---|---|
ip | ip a | Standard method. Shows full network details. | Detailed Info |
hostname | hostname -I | Cleanest method. Shows only the IP numbers. | Simple Text |
nmcli | nmcli device show | Network Manager. Good for detailed device info. | Configuration Data |
curl | curl ifconfig.me | External access. Shows your Public IP. | Single IP |
Method 1: Use the ip Command (Recommended)
The most modern and standard way to check IP address in Ubuntu is using the ip command. It has replaced the older ifconfig tool in most Linux distributions.
Usage
Open your terminal and type:
ip a
(You can also use ip addr show)
How to Read the Output
Look for the interface named eth0 (for wired connections) or wlan0 (for Wi-Fi).
- Find the line starting with
inet. - The number following it is your Private IP Address.
Example:
See also: Mastering the Linux Command Line — Your Complete Free Training Guide
inet 192.168.1.15/24 brd 192.168.1.255 ...
(In this case, your IP is 192.168.1.15)
Method 2: Use the hostname Command (Simplest)
If you want to check IP address in Ubuntu without seeing complex technical details, the hostname command is the fastest option. It filters out everything except the IP addresses.
Usage
hostname -I
Output
192.168.1.15 172.17.0.1
It simply lists the IP addresses assigned to your machine, separated by spaces.
Method 3: Use nmcli (Network Manager CLI)
For users who want a structured view of their network devices, nmcli is a powerful tool to check IP address in Ubuntu.
Usage
nmcli device show
Output
Look for the line IP4.ADDRESS[1]. This will display your current IP address clearly alongside your gateway and DNS settings.
Method 4: How to Check Public IP Address
The methods above show your local IP. If you need to know how websites see you (your Public IP), you must query an external server.
Usage
curl ifconfig.me
Output
203.0.113.45
(This is the IP address assigned to you by your Internet Service Provider)
FAQ: 5 Common Questions
- Q: Why does
ifconfigsay “command not found”?- A: It is deprecated in Ubuntu; install it via
sudo apt install net-toolsor useip a.
- A: It is deprecated in Ubuntu; install it via
- Q: Which IP is “Localhost”?
- A: Localhost is always
127.0.0.1(the loopback interfacelo).
- A: Localhost is always
- Q: How do I find my Default Gateway (Router IP)?
- A: Run
ip route | grep defaultto see the gateway address.
- A: Run
- Q: Why do I see two different IP addresses?
- A: You likely have both Wi-Fi and Ethernet connected, or a VPN/Docker container running.
- Q: How do I copy my IP to the clipboard?
- A: Run
hostname -I | xclip -selection clipboard(requiresxclipinstalled).
- A: Run




