View the IP of Centos7 in the virtual machine

The reason for checking the IP here is that when we want to build a Centos remote tool Xshell to connect to Centos later, we need an IP address, so we will first

Learn to view the IP address of Centos7 in the virtual machine

 

First, we log in to the operating system username root password 123456

Then we enter ip to query the name ip addr. You can also enter ifconfig to view ip, but this command will have 3 entries. The ip address of centos is the inet value in the ens33 entry.aa.jpg

 

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

 

Next, check the configuration of the ens33 network card: vi /etc/sysconfig/network-scripts/ifcfg-ens33 Note the space after vi

vi is the meaning of Linux's built-in text editor command to open files

 

bb.jpg

 

From the configuration list, it can be found that CentOS 7 does not start the network card by default (ONBOOT=no).

 

Change this item to YES (ONBOOT=yes),

cc.jpg

 

Then press Esc to exit and then enter and exit the command: wq and then press Enter (Note: wq means to save and then exit, and we will talk about vi later)

 

Then restart the network service: sudo service network restart 

 

ee.jpg

 

Then we enter the ip addr command again

ff.jpg

 

Here the inet property shows the IP 192.168.1.107 in the virtual machine (yours may be different from mine)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325206855&siteId=291194637