![How to connect virtual machine centos to the Internet](https://img.php.cn/upload/article/000/000/020/5e6af6ca523d8137.jpg)
How to connect virtual machine centos to the Internet? How to access the Internet with a CentOS7 virtual machine
Edit the virtual machine settings, select the NAT address translation method for the network adapter mode
![1584068008262508.png How to connect virtual machine centos to the Internet](https://img.php.cn/upload/image/352/973/296/1584068008262508.png)
Open the VMware menu, edit -Virtual network editor, in the pop-up dialog box, click NAT settings, write down the subnet IP, subnet mask, gateway address information
![1584068013801220.png How to connect virtual machine centos to the Internet](https://img.php.cn/upload/image/740/719/657/1584068013801220.png)
![1584068018636668.png How to connect virtual machine centos to the Internet](https://img.php.cn/upload/image/783/459/972/1584068018636668.png)
##Enter the CentOS7 virtual machine in VMware, and the command to enter the directory is as follows:
cd /etc/sysconfig/network-scripts
Copy after login
The command to display the files in the current folder is as follows
The first ifcfg-ens33 is the CentOS7 network configuration to be edited File, the specific file name may be different, the prefix is ifcfg-ens
![1584068033247190.png How to connect virtual machine centos to the Internet](https://img.php.cn/upload/image/302/751/406/1584068033247190.png)
To edit the file, the command is as follows
vi ifcfg-ens33
Copy after login
as shown in the figure below. Note that you need to change it based on the information you see in the second step. IPADDR must be in the subnet. The gateway and subnet mask are the same as in the second step. In addition, you need to configure DNS, etc. Finally, save and exit.
![1584068041910540.png How to connect virtual machine centos to the Internet](https://img.php.cn/upload/image/525/583/942/1584068041910540.png)
The next command to restart the network service is as follows:
service network restart
Copy after login
![1584068049471235.png How to connect virtual machine centos to the Internet](https://img.php.cn/upload/image/638/752/762/1584068049471235.png)
Try to ping the Baidu server again and it will be normal. The command is as follows
ping www.baidu.com
Copy after login
![1584068058673880.png How to connect virtual machine centos to the Internet](https://img.php.cn/upload/image/673/562/861/1584068058673880.png)
Recommended video tutorial for learning Linux:
https://www .php.cn/course/list/33.html
The above is the detailed content of How to connect virtual machine centos to the Internet. For more information, please follow other related articles on the PHP Chinese website!