How to Check IP Address in Linux

If you are attempting to connect to a headless Linux server via SSH, or trying to configure a firewall to allow traffic from a specific machine, you cannot simply guess the machine’s address. You must ask the operating system to print the exact, mathematically assigned IP address currently bound to the physical network card.

In the 1990s and early 2000s, almost every tutorial on the internet told you to type ifconfig to find this information. Do not use ifconfig. That command was formally deprecated over a decade ago; it is completely obsolete, fundamentally broken in modern networking environments, and is no longer installed by default on modern Linux distributions like Ubuntu or Debian.

You must use the modern ip command suite.

Method 1: Finding Your Private IP Address (The Modern Standard)

If your Linux machine is sitting inside a house or an office building connected to a Wi-Fi router, it has a “Private” IP address (usually starting with 192.168.x.x or 10.0.x.x). This address is invisible to the outside world; it only exists so computers inside the same building can talk to each other.

To find this address:

  1. Open your terminal.
  2. Type the following command and press Enter:

ip addr show

The terminal will print out a dense block of highly technical networking data. Look for the physical network interface that is actually connected to the internet (it is usually named something like eth0 for a wired connection, or wlan0 for Wi-Fi). Look at the indented text directly underneath that interface name.

You will see a line that begins with the word inet. The numbers immediately following inet are your private IP address (e.g., inet 192.168.1.45/24).

(Pro tip: If ip addr show spits out too much garbage data and you just want the raw numbers, type hostname -I (capital i) instead. It will simply print the IP address and nothing else).

Method 2: Finding Your Public IP Address

If you are hosting a Minecraft server on your Linux machine and you want your friends across the country to connect to it, they cannot use the Private IP address. They must use the Public IP address—the address your Internet Service Provider assigned to the router that faces the outside world.

Your Linux machine cannot actually see its own Public IP address directly, because it is hiding behind the router. To find it, the machine must shout out to the internet and ask a third-party server to repeat the address back to it.

  1. Open your terminal.
  2. You will use the curl command to pull a raw text string from a dedicated IP-checking website. Type:
curl ifconfig.me

The terminal will pause for about half a second while it reaches out to the server, and then it will print your exact Public IP address directly onto the command line (e.g., 203.0.113.50).

Warning: You should never post your Public IP address on a public forum or social media, as malicious actors can use it to launch DDoS attacks against your home network.

Get the best tech tips delivered straight to your inbox.

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