Reproduced from: http://jingyan.baidu.com/article/c843ea0ba8b70677931e4adc.html
All operations of the virtual machine do not affect the real machine, even if the virtual machine crashes or the virus, so we do some of the dangerous operations can be done in the virtual machine, so how to enable virtual machines to access the network, today, in the CentOS system as an example, to tell you how to access the network in the simplest way.
1, first open the virtual machine
Right-click on the lower right corner of the network connection
Click on the network in the pop-up box
Click on the Settings screen-network-connection mode selection-Bridging network card-OK
2, open the CentOS virtual machine terminal, is the command line
Switch to root and edit the NIC file
shell#cd/etc/sysconfig/network-scripts/
shell# Vim IFCFG-ENP0S3
3, the main modification of two items:
Bootproto=dhcp
Onboot=yes
Change the two items in the configuration to the same as above, DHCP for dynamic get ip,onboot=yes for boot
4. Save and exit.
Reboot network card
Shell#service Network Restart
Or
Shell#systemctl Restart Network (CENTOS7 version command)
5, do a simple test, ping Baidu
Shell#ping www.baidu.com
As the figure, that is ping pass, means that you can access the Internet
"Note" 3rd--> 4th: Use the VI command to save, I use is: press ESC to jump to the command mode, and then: Wq Save the file and Exit VI.
5th, when the ping command succeeds, use CTRL + C (interrupt command) to exit