How to Check the IP Address of an Ubuntu Server

When managing an Ubuntu server—especially a headless setup without a graphical interface—knowing the machine’s IP address is the very first step required to connect via SSH, configure a firewall, or set up a web server.

Every server typically has at least two IP addresses: a local (private) IP address used for communication within your home or corporate network, and a public IP address used to communicate with the wider internet. You can find both of these quickly using standard terminal commands.

How to Find the Local IP Address

The local IP address (often starting with 192.168.x.x or 10.x.x.x) is assigned by your router. This is the address you use to SSH into the server from another computer on the same Wi-Fi or Ethernet network.

Historically, Linux administrators used the ifconfig command, but this has been deprecated in modern Ubuntu releases in favour of the more robust ip command.

  1. Open your terminal application.
  2. Type the following command and press Enter:
ip addr show

This command outputs a lot of networking data. You need to look for your primary network interface. If you are connected via an Ethernet cable, it is usually named something like eth0, eno1, or enp3s0. If you are on Wi-Fi, it will likely start with wl.

Under your active interface, look for the line starting with inet. The numbers immediately following it (e.g., 192.168.1.55/24) represent your local IP address.

A Faster Alternative

If you want a cleaner output without all the extra routing data, you can use the hostname command:

hostname -I

This will simply print the local IP address (or multiple addresses if you have multiple network cards) on a single, easy-to-read line.

How to Find the Public IP Address

Your public IP address is assigned by your Internet Service Provider (ISP) and is how the rest of the world sees your server. You cannot find this by querying your local network card; your server must ask an external service to identify it.

The easiest way to do this from the terminal is by using the curl command to query a lightweight IP identification service, such as ifconfig.me or icanhazip.com.

  1. In your terminal, type the following command:
curl ifconfig.me
  1. Press Enter.

The terminal will wait a brief moment to connect to the external server, and then print your public IPv4 address directly to the screen. If curl is not installed on your system, you can install it using sudo apt install curl.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.