Several ways to view IP with Linux commands

1. Use the ifconfig command to view the IP

In Linux and Unix systems, the current IP address of the machine can be easily checked using the ifconfig command. Open the command line terminal, enter the ifconfig command, and press the Enter key to see the network configuration information of the machine, including IP address, subnet mask, gateway, etc.

If the machine is connected to multiple networks, it will display the configuration information of multiple network interfaces, and you can connect to the network through wired network cards, wireless network cards, virtual network cards and other ways.

2. Use the ip command to view the IP

In the Linux system, you can also use the ip command to view the network configuration information and IP address of the current machine. Unlike ifconfig, the ip command will only display the main IP address information of the current machine, which is very suitable for viewing on the command line.

Similarly, open the command line terminal, enter the ip addr command, and press the Enter key to see the IP address of the current machine.

3. Use the hostname command to view the IP

In addition to the two commands ifconfig and ip, you can also use the hostname command to view the IP address of the current machine. The hostname command is generally used to view the host name, but after adding the -i parameter, you can view the IP address.

Enter the hostname -i command in the terminal and press the Enter key to see the IP address information of the current machine, which is very convenient.

4. Use the ping command to get the IP address

When you want to get the IP address of another machine, you can use the ping command. The ping command is generally used to test network connectivity and latency, but when you ping, it will display the IP address of the machine being pinged.

Enter ping hostname or ping IP address in the command line terminal, and press Enter to view the IP address information of the pinged machine.

Guess you like

Origin blog.csdn.net/qq_37247026/article/details/131625531