How to Find Your IP Address in Ubuntu Linux Using the Terminal

Whether you are setting up a local server, configuring a firewall, or troubleshooting a network connection, knowing your computer’s IP (Internet Protocol) address is a fundamental requirement. If you are learning how to use the command line, discovering how to find your IP address in Ubuntu Linux is one of the most basic and essential tasks you will perform.

While you can easily find your IP address through the Ubuntu graphical settings menu, the terminal is much faster and essential for managing headless servers. In this guide, we will explore the simplest commands to reveal both your local and public IP addresses.

How to Find Your Local IP Address

Your local (or private) IP address is the address assigned to your computer by your home router. It is used to communicate with other devices on your local network.

Method 1: Using the “ip” command (Recommended)

The modern and standard way to check network interfaces in Ubuntu is using the ip command.

  1. Open your terminal by pressing Ctrl + Alt + T.
  2. Type the following command and press Enter: ip a
  3. The terminal will output a block of text detailing your network interfaces. Look for the interface connected to your network (usually starting with eth for ethernet or wlan for Wi-Fi).
  4. Beside the word inet, you will see your local IP address (e.g., 192.168.1.15).

Method 2: Using the “hostname” command

If you want a cleaner output without all the extra network interface data, you can use the hostname command.

  1. Open the terminal.
  2. Type hostname -I (note the capital “i”) and press Enter.
  3. Your local IP address will be printed directly on the screen.

How to Find Your Public IP Address

Your public IP address is the address assigned to your router by your Internet Service Provider (ISP). This is the address that the rest of the internet sees when you connect to a website.

To find your public IP address from the command line, you must query an external server. The easiest way to do this is using the curl command.

  1. Open the terminal.
  2. Type curl ifconfig.me and press Enter.
  3. Your public IP address will be returned instantly.

Note: If you receive an error saying curl is not installed, you can install it quickly by running sudo apt install curl.

Learning how to find your IP address in Ubuntu Linux using the terminal is incredibly straightforward. By memorising simple commands like ip a and curl ifconfig.me, you can rapidly identify your network credentials and proceed with configuring your servers, SSH connections, or local firewalls efficiently.

Leave a Reply

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

Get the best tech tips delivered straight to your inbox.

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

Receive our best articles and tips delivered straight to your inbox.