How to Check IP Address in Ubuntu: A Complete Guide

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:

  1. Private IP (LAN): Used within your home or office network (e.g., 192.168.x.x).
  2. 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.

Quick Summary: IP Address Commands

CommandSyntaxBest Used ForOutput Type
ipip aStandard method. Shows full network details.Detailed Info
hostnamehostname -ICleanest method. Shows only the IP numbers.Simple Text
nmclinmcli device showNetwork Manager. Good for detailed device info.Configuration Data
curlcurl ifconfig.meExternal 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

  1. Q: Why does ifconfig say “command not found”?
    • A: It is deprecated in Ubuntu; install it via sudo apt install net-tools or use ip a.
  2. Q: Which IP is “Localhost”?
    • A: Localhost is always 127.0.0.1 (the loopback interface lo).
  3. Q: How do I find my Default Gateway (Router IP)?
    • A: Run ip route | grep default to see the gateway address.
  4. 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.
  5. Q: How do I copy my IP to the clipboard?
    • A: Run hostname -I | xclip -selection clipboard (requires xclip installed).
David Cao
David Cao

David is a Cloud & DevOps Enthusiast. He has years of experience as a Linux engineer. He had working experience in AMD, EMC. He likes Linux, Python, bash, and more. He is a technical blogger and a Software Engineer. He enjoys sharing his learning and contributing to open-source.

Articles: 595

Leave a Reply

Your email address will not be published. Required fields are marked *