Centos7 communicates with the host over the Internet through NAT
Previously, Centos7 was recorded to implement Host-only communication between hosts and virtual machines.
In Host-Only mode, virtual machines do not seem to be able to connect to the Internet (some people on the Internet say yes, some say no, and I am not very clear about this)
But in NAT mode, at least I tried it. The virtual machine can not only communicate with the host, but also connect to the Internet.
Why do I need to connect to the internet? When installing some software, you may need to install the dependent package environment required by these software. In many cases, you can directly connect to the yum source through yum to download and install the software from the Internet, therefore, it is necessary to connect the VM to the Internet.
Previously, we mentioned that Host-Only is related to VMnet1, while NAT is related to VMnet8.
First, find VMnet8 in the host network link.
Set it like this (I don't seem to have set it. Open it like this. Of course, the ip addresses of each computer are different)
Continue to open here:
Well, record this: GATEWAY = 192.168.6.2
Then confirm the DHCP address segment:
Well, record the following:
NETWORK = 192.168.6.0
NETMASK = 255.255.255.0
Remember the starting IP address and ending IP address. When you set IPADDR = XXX. XXX in the future
Set the virtual machine:
OK, go to Virtual Machine Settings
Open the console: cd/etc/sysconfig/network-scripts/
The configuration is as follows:
NETMASK, NETWORK, and GATEWAY have been recorded.
IPADDR is also mentioned above. It can be done between DHCP and DHCP.
HWADDR is the mac address. If you do not know it, Baidu.
The key is this DNS1. What is this?
Open the host. Note that the host is not a virtual machine. Open cmd, ipconfig/all.
This is 192.168.1.1.
After saving, remember the following command:
Service network start
If this command is not executed, the configuration does not take effect.
Finally, let's see if you can access the Internet:
Everything OK
Reference link: http://www.iyunv.com/thread-54435-1-1.html