An IP address is the network identity of your machine — the number that allows other devices and servers to find and communicate with it. Every Linux system administrator, developer working with SSH connections, or user troubleshooting a network issue needs this figure quickly. Ubuntu offers multiple ways to retrieve it, from a single clean command to a full network interface diagnostic, and the right choice depends on how much detail you need and whether you’re working on a server or a desktop

Private IP vs Public IP — Understanding the Difference
Before running any command, clarify which IP address you actually need.
A private IP address (also called a local or LAN address) is assigned by your router to your machine within the local network. It typically looks like 192.168.x.x or 10.x.x.x and is used for communication within your home or office network. This is the address you share when setting up SSH connections locally, configuring services, or troubleshooting LAN connectivity.
A public IP address is the address the internet sees when your machine makes requests outside the local network. It’s assigned by your ISP and is the same for every device on your network sharing one internet connection. You need this for external server configurations, remote access setups, or verifying which IP appears in web server logs.
The commands below primarily retrieve private IPs. The public IP requires a separate method covered at the end.
Method 1: ip addr — The Modern Standard Command
The ip command from the iproute2 suite is the current standard for network management on Ubuntu. It replaced the older ifconfig tool, which is now deprecated and absent from most modern Ubuntu installations.
Open a terminal (press Ctrl + Alt + T on Ubuntu desktop) and run:
bash
ip addr
Or the shorthand:
bash
ip a
The output lists every network interface on the system with detailed information. Look for the interface named eth0 (wired Ethernet connection) or wlan0 (Wi-Fi connection) — on newer Ubuntu systems these may appear as ens33, enp3s0, or wlp2s0 depending on hardware. Find the line beginning with inet under your active interface — the number following it is your private IPv4 address in CIDR format, such as 192.168.1.105/24.
For a cleaner, more readable output showing only IPv4 addresses without the technical detail:
bash
ip -4 -brief address show
This returns a compact table with interface name, status, and IP address — easier to parse at a glance.
Method 2: hostname -I — Quickest Single-Line Output
When you simply want the IP address and nothing else, this is the fastest option:
bash
hostname -I
The output is just the IP address — or multiple IP addresses separated by spaces if your machine has several network interfaces or VPN connections active. No headers, no interface names, no subnet masks. Clean and script-friendly.
Note that on some minimal Ubuntu server installations, the hostname command may not be available by default. In those cases, the ip command serves as the reliable fallback.
Method 3: nmcli — NetworkManager Detailed View
For Ubuntu desktop systems using NetworkManager to manage connections, nmcli provides a structured network overview:
bash
nmcli device show
The output is organised by interface and includes not just the IP address but also the default gateway, DNS servers, and connection type. Look for the line IP4.ADDRESS[1] — the value next to it is your IPv4 address with subnet mask.
For a more targeted query showing only active connections:
bash
nmcli -p device show | grep IP4
This filters the output to display only IPv4-related lines across all interfaces — useful when managing multiple network connections simultaneously.
Method 4: GUI Method — Settings → Network
For Ubuntu desktop users who prefer not to use the terminal, the graphical route is equally simple.
Open Settings from the application menu. Click Network in the left sidebar. If connected via Ethernet, click the gear icon next to the wired connection. If on Wi-Fi, click Wi-Fi, then the gear icon next to your connected network. The network details panel shows your IPv4 Address clearly labelled — no commands required.
Method 5: Checking Public IP Address
To find your public IP — what the internet sees — use the curl command to query an external service:
bash
curl ifconfig.me
Or alternatively:
bash
curl icanhazip.com
Both return just your public IPv4 address as a single line. If curl isn’t installed, run sudo apt install curl first. This method requires an active internet connection since it contacts an external server to retrieve the public-facing IP.
When ifconfig Doesn’t Work
Many Ubuntu users familiar with older Linux references still try ifconfig out of habit. On Ubuntu 18.04 and all later versions, ifconfig is no longer included by default. Running it returns command not found. Either install the deprecated net-tools package via sudo apt install net-tools to restore it, or simply use ip addr — the modern equivalent that provides the same information and more.
FAQs
Q: What is the difference between ip a and hostname -I in Ubuntu?
A: ip a shows all network interfaces with full technical detail including IPv6 and subnet masks. hostname -I returns just the IP address in a clean single-line output — faster for scripts and quick checks.
Q: Why does ifconfig not work on my Ubuntu system?
A: ifconfig was deprecated and removed from default Ubuntu installations from version 18.04 onward. Use ip addr as the modern replacement.
Q: Can I check the IP address of another device on my network from Ubuntu?
A: Yes. Use arp -a or nmap -sn 192.168.1.0/24 (requires nmap installed) to scan the local network and list connected devices with their IP addresses.
Q: My ip addr output shows multiple inet lines. Which one is my IP address?
A: The loopback address (127.0.0.1) is not your network IP — it’s the localhost identifier. Look for inet entries under interfaces named eth0, wlan0, or ens/enp-style names for your actual network IP.
Q: Does my Ubuntu server IP change after reboot?
A: On DHCP-assigned networks, yes — the IP can change between reboots. For a permanent fixed address, configure a static IP either through the router’s DHCP reservation settings or through Ubuntu’s Netplan configuration files.