How to get the IP address of CentOS

In the CentOS operating system, there are many ways to obtain the IP address of the current system. Several commonly used methods will be introduced below.

Method 1: Use ifconfig command

ifconfig is a commonly used command line tool used to display and configure network interface information. To view your CentOS IP address, you can follow these steps:

  1. Open a terminal or command line interface.
  2. Enter the following command and press Enter:
ifconfig
  1. In the output, look for the line that starts with "inet" followed by your IP address. Typically, this line is of the form:
inet 地址:你的 IP 地址  子网掩码 子网地址

For example:

inet 地址:192.168.0.100  子网掩码:255.255.255.0  子网地址:192.168.0.0

Method 2: Use the ip command

The ip command is another tool for displaying and configuring network interfaces, which provides more functionality and options. To get the IP address of CentOS, you can follow these steps:

  1. Open a terminal or command line interface.
  2. Enter the following command and press Enter:
ip addr show
  1. In the output, find the line starting with "inet" followed by

Guess you like

Origin blog.csdn.net/Pjv____/article/details/133239958