Knowing the IP address of your RHEL/CentOS server is essential for various network-related tasks, such as troubleshooting, configuring network settings, or accessing your server remotely.
In this quick how-to, we will walk you through the steps to display the IP address on a RHEL/CentOS system using different commands.
Option 1: Using the `ip` Command:
The ip command is a powerful utility for managing network interfaces and retrieving network information. Open your terminal or SSH into your RHEL/CentOS server and execute the following command:
ip addr show
This command will display detailed information about all the network interfaces on your system, including their IP addresses.
[root@centos58 ~]# ip addr show 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:0c:29:a1:17:ad brd ff:ff:ff:ff:ff:ff inet 192.168.1.53/24 brd 192.168.1.255 scope global eth0
Option 2: Using the `ifconfig` Command:
The ifconfig command is a traditional utility for configuring and displaying network interfaces. While it may not be available by default on newer versions of RHEL/CentOS, you can still install it if needed. To check if it is available, run the following command:
ifconfig
[root@centos58 ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:A1:17:AD inet addr:192.168.1.53 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:72408 errors:0 dropped:0 overruns:0 frame:0 TX packets:64177 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:24607729 (23.4 MiB) TX bytes:6678283 (6.3 MiB) Interrupt:75 Base address:0x2000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
If the ifconfig command is not found, you can install it by executing the following command:
sudo yum install net-tools
Once installed, run the ifconfig command again, and it will display the IP addresses of your network interfaces.
Option 3: Using the `hostname` Command:
The hostname command can also provide you with the IP address of your RHEL/CentOS server. Simply enter the following command:
hostname -I
This command will output the IP addresses associated with the hostname of your server.
Option 4: Using the `nmcli` Command:
If you have the NetworkManager service running on your RHEL/CentOS system, you can utilize the nmcli command to retrieve network information. Run the following command:
nmcli device show
This command will display detailed information about the network devices on your system, including their IP addresses.
Conclusion:
In this guide, we have explored different methods to display the IP address on a RHEL/CentOS system. By using the ip command, the ifconfig command (if installed), the hostname command, or the nmcli command, you can easily obtain the IP address information of your server. Understanding your server’s IP address is vital for managing network settings, troubleshooting connectivity issues, and accessing your server remotely.
If you have any further questions or suggestions, please feel free to comment below.