How to Get IP Address in CentOS

Muhammad Husnain Feb 02, 2024
  1. Introduction to CentOS
  2. CentOS Architecture
  3. Pros of Using CentOS
  4. Get IP Address in CentOS
How to Get IP Address in CentOS

This trivial guide is a small introduction to CentOS and then a brief discussion on how we can get the server IP address in CentOS using the command-line interface (CLI).

This article will discuss some of the commands for the said purpose and their usage. Let’s begin with the introduction of CentOS.

Introduction to CentOS

CentOS, the shorthand for Community Enterprise Operating System, is a Linux distribution founded by Gregory Kurtzer that offers a free enterprise class and is an open-source operating system.

It is suited to Red Hat Enterprise Linux (RHEL), its upward source. RHEL is an enterprise-class operating system but is not free of cost and generally requires a payment for its subscription.

CentOS developers use the RHEL source code to develop a product that is substantially relatable to RHEL. Only community and web portals provide technical support for this.

CentOS is one of the most stable and trustworthy Linux distributions available. It is the preferred server operating system.

CentOS is a free version of Red Hat Linux that includes some of its features. Unlike Red Hat, it is an open-source operating system.

CentOS Architecture

Its underlying architecture is similar to all the other Linux distros. Similar to other distributions, it also supports only the -86 and x64 bit architecture, which means it can only run on 32-bit and 64-bit platforms.

  1. The lowest layer comprises physical and hardware devices such as computers, networking and storage devices.
  2. On top of this, the kernel is placed. The kernel is the most fundamental part of OS because it directly interacts with the hardware.
  3. The next layer is the shell, which acts as an interface between the user and the kernel.
  4. On the top layer is the application layer, which is used for interaction between shell and kernel to perform user-defined tasks such as File Explorers, media players, text editing software, etc.

Pros of Using CentOS

  1. It is light, efficient, and speedy.
  2. It’s open-source and free, and it’s enterprise-ready.
  3. Some open-source server software is also packaged with Apache Web, CUPS, MySQL, and version control tools like Git, which are pre-installed.
  4. Best community support, including the ability to submit defects to bugs.centos.org.
  5. It contains nearly the same functionalities as the commercial Red Hat Enterprise Linux. This is also accessible for no cost!
  6. CentOS is frequently favored (even above Ubuntu) over other open-source and free Linux distributions because of its stability and less frequent package upgrades.

Get IP Address in CentOS

Within a local network, private IP addresses are used for communication. Because private IP addresses cannot be routed, no traffic from the outside network may be transmitted to them.

You may need to know your system’s private IP address for various reasons, including setting up a network-related application, enabling remote administration, or troubleshooting.

Below are some methods to find the IP address using the command-line interface (CLI).

Use the ifconfig Command

ifconfig is the acronym for Interface Configuration. This is the most widely used command in the Linux world.

Along with the local IP address, it gives us many other network details, so to get the IP address, we will pipe it with grep to get the IP address exactly. This is depicted in the image below.

ifconfig command

Use the ip a Command

This is the simplest and the shortest command to find the IP address. Write three characters only, ip a, and get the local IP address as demonstrated in the image below.

ipa command

Use the nmcli Command

This command is used to find the status of different networks and thus shows the IP address of that network too. So this can also be used to find the IP address.

nmcli command

Use the ip addr Command

This works the same as the ip a command, or we can say ip a is the shorthand of ip addr. The output of both commands is the same and can be used interchangeably.

ip addr command

Use the hostname Command

The hostname command is typically used to determine the system’s hostname. Using the hostname command with the -l option, on the other hand, gives you IP address information.

hostname command

Use the ip route Command

In Linux OS, the ip route command is used to configure and displays static routes. This command also displays a system’s private IP address.

To find your private IP address, run the following command in Terminal.

ip route command

Muhammad Husnain avatar Muhammad Husnain avatar

Husnain is a professional Software Engineer and a researcher who loves to learn, build, write, and teach. Having worked various jobs in the IT industry, he especially enjoys finding ways to express complex ideas in simple ways through his content. In his free time, Husnain unwinds by thinking about tech fiction to solve problems around him.

LinkedIn