CentOS 7 virtual machine link network

The first step, we enter the /etc/sysconfig/network-scripts directory to see if there is a file in the form of ifcfg-XXX in this directory: for example, mine is:

 

 

If you can't see the files starting with ifcfg- (except ifcfg-lo), it means that the network card device is not correctly recognized. It may be that the version of the centos image you downloaded is inconsistent with the version of centos you selected when installing centos. For example, the centos image is 64-bit, but installed according to 32-bit. this. . Reinstall it, at least I didn't find a good way

The second step is as follows:

    First check your computer ip, enter cmd, enter ipconfig /all, the results are as follows:

     

 

Then in VMware, click "Edit" - "Virtual Network Editor" in turn, as shown below, I chose NAT mode:



 

In order to be able to use static IP, do not check the "Use local DHCP service to assign IP to virtual machine" option here. Then configure the subnet IP. The subnet IP and the host's IP must not be in the same address range. Otherwise, even if the virtual machine can access the Internet, the network will be slow and unstable. The ip segment of my host is 192.168.1.51, so I configured 192.168.10.xxx to avoid the ip segment of the host. Anyway, the third number of ip is between 0 and 254 and not 1. Nat mode is equivalent to configuring a sub-router. Friends who have set up multi-level routing should understand this. You can reasonably configure a subnet IP based on the IP of your own machine.

 

 

On this interface, click "NAT Settings" to view the gateway of the virtual machine. This gateway will be used in the third step. My gateway here is 192.168.10.2. As shown in the figure:



 

 

 

 

third step:

Edit the file /etc/sysconfig/network-scripts/ifcfg-eno16777736 with root privileges, the effect is as follows:

TYPE=Ethernet
BOOTPROTO=static   #Set static Ip
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=4f40dedc-031b-4b72-ad4d-ef4721947369 ONBOVICE =   here
#y If it is no, it will be changed to yes, indicating that the network card device will automatically start PEERDNS=yes PEERROUTES=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_PRIVACY=no





GATEWAY=192.168.10.2 #The   gateway address here is the gateway address obtained in the second step
IPADDR=192.168.10.150 #Configure   ip, in the second step, the ip has been set in the range of 192.168.10.xxx,

I just set it to 150, as long as it is not the same as the gateway.
NETMASK=255.255.255.0 #Subnet mask
DNS1=202.96.128.86 #dns server 1, fill in the dns server address displayed in cmd

 

I have marked the key parameters with colored shading, and the others should be kept as default. After confirmation, save and exit.

 

 

Step 4: Restart the network card service, execute service network restart, and then finally be able to access the Internet: Ping Baidu's domain name

  



 

browser



 

 

Source: http://blog.csdn.net/a785975139/article/details/53023590

 

 

 

 

 

 

Guess you like

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