Find the IP of a Linux Server via the Command Line

Reading Time: 2 minutes

Knowing your server's IP address(s) can be useful information to have for various reasons. After all, other than your domain, the server's IP is the main address used to reach the server. Knowing a server's IPs may be necessary when making changes to: DNS, networking, and security. A server may have a single IP, or multiple IPs, but sometimes, you may need a quick method to double-check since it's easy to forget.

In this tutorial, we will show you how to verify the IPs of any modern Linux server. To follow along, you will simply need access to the server via SSH or TTY.

Find the IP of a Linux Server via the Command Line

Prerequisites

  • This tutorial requires basic knowledge of SSH and command line.
    See our KB article on command line access via SSH.
  • You must have SSH access to the server.

Check IPs with Command Line

Step 1.
Begin the process by logging into your server via SSH.

ssh user@liquidweb.example

Step 2.
Now logged in via SSH, run the following command to check the servers IP.

ip route

This command is using the `ip` tool and is calling the `route` object.
This command prints the current routing table.

Reading the Results

Once we execute the command you will see an output similar to the text below.

default via 203.0.113.1 dev eth0
 203.0.113.0/24 dev eth0 proto kernel scope link src 203.0.113.86
 198.51.0.0/16 dev eth0 scope link metric 1002

This information shows us the servers IP routing table, which is essentially a set of rules used to determine where data will be directed.

When using this technique to find a server's IP, you will want to notice the lines containing `src` followed by an IP address. On these lines, the IP address following `src` are the IP(s) configured on the server.

Any device using IP addresses will have a routing table that is used to determine the behavior of the networking devices. In the example above, we can see the servers routing table, showing that the server has an IP address of `203.0.113.86`.

While it may not look like much to new users, these lines are filled with valuable information. Each line of the routing table is there to describe a different behavior or condition. More information on these settings can be found in the ip commands man pages. These settings are found in the command line using `man ip route`. Additionally, we can read the man page for the IP command online.

Conclusion

We pride ourselves on being The Most Helpful Humans In Hosting™!

Our Support Teams are filled with experienced Linux technicians and talented system administrators who have intimate knowledge of multiple web hosting technologies, especially those discussed in this article.

Should you have any questions regarding this information, we are always available to answer any inquiries with issues related to this article, 24 hours a day, 7 days a week 365 days a year.

If you are a Fully Managed VPS server, Cloud Dedicated, Private Cloud Powered by VMware, Private Parent server, Managed Cloud Servers, or a Dedicated server owner, and you are uncomfortable with performing any of the steps outlined, we can be reached via phone at @800.580.4985, a chat or support ticket to assisting you with this process.

Avatar for David Richards

About the Author: David Richards

David Richards has been an educator, a Technology Director, and now a Windows Administrator for 20+ years. He’s an English major with a love for technology and helping others find ways to use technology more effectively. In his free time, Dave loves to read, play games, and spend time his family.

Latest Articles

Blocking IP or whitelisting IP addresses with UFW

Read Article

CentOS Linux 7 end of life migrations

Read Article

Use ChatGPT to diagnose and resolve server issues

Read Article

What is SDDC VMware?

Read Article

Best authentication practices for email senders

Read Article