Solve the problem that the IP of the Linux virtual machine cannot be displayed

Table of contents

question:

There are two solutions for you to choose from.

The first solution:

The second solution:

1. View the configuration of the ens33 network card

2. Modify the file

extension:


question:

When the Linux command ip a checks the IP, the solution to the IP cannot be displayed. 


There are two solutions for you to choose from.

The first solution:

The newly built virtual machine, the default network card is not turned on!

Enter the command below, and the root user has to operate it!

The su root command switches users.

Enter the ifup ens33 command, which can be used to start the ens33 network card interface in the Linux system.

Solve problems efficiently and quickly.


The second solution:

It is found that ens33 does not have the attribute of inet, so it is impossible to connect to the virtual machine through the IP address.

1. View the configuration of the ens33 network card

In the Linux system, files can be edited through the vi/vim command. Enter the following command to edit:

vi /etc/sysconfig/network-scripts/ifcfg-ens33

Note that there is a space after vi, vi is a built-in text editor command in Linux, which means to edit files.

2. Modify the file

(1) Press the i key to enter the edit (insert) mode, and you can edit the text at this time.

(2) Edit the text to the desired result, and press the Esc key to exit the editing mode. Type ":wq" to save the file and exit vi.

Among them, ":w" means to save, and ":q" means to quit.

(3) Then restart the network service and enter the following command:

 systemctl restart network 

(4) Re-enter the view ip command ip a, and you will find that the ip is displayed.


extension:

Some commonly used vi/vim editing shortcuts include:

i enter edit mode  
x delete character
dw delete word
dd delete line
o create new line
Esc exit edit mode
: wq save and exit

:q! Exit without saving

After mastering these basic operations, you can use vi/vim to modify various configuration files and code files under Linux. 

Guess you like

Origin blog.csdn.net/Microhoo_/article/details/132365135