Home > Article > Operation and Maintenance > Static IP connects to the external network in NAT mode in centos
When using a Linux virtual machine, the yum command is usually used to install software. However, this command requires an external network connection to download the software, and using maven to download the jar package also requires an external network. The virtual machines can ping each other on the internal network, but cannot ping the external network, so through experiments, I finally found the solution:
1. In the cmd command line of the physical machine, use the ipconfig command to view the IP configuration , as can be seen from the figure, the subnet IP of the physical machine is 192.168.0.0, the subnet mask is 255.255.255.0, and the gateway is 192.168.0.1
C:\Users\huanongying>ipconfig
2. Close the virtual machine for which the IP is to be configured, and then click Edit -> Virtual Network Editor on the VMware main panel
##3. Select NAT mode, set the subnet IP and subnet mask to be consistent with the physical machine, refer to the values obtained in step 14. Click NAT Settings, set the gateway value to be consistent with the physical machine, click OK to save the configuration and return to the virtual network editor panel, click Apply to make steps 3 and 4 take effect (
It is best to click Apply , at first it was because I didn’t click on the application, so I couldn’t access the Internet), and finally click OK to exit the virtual network editor
5. Find the VMnet8 network card in the network connection of the physical machine, configure the IP address, subnet mask andpreferred DNS (you cannot connect to the external network without DNS) . The network segment of the IP is consistent with the physical host, which is 192.168.0, the host segment is 1, the subnet mask is consistent with the physical machine, and DNS
can be configured to be the same as the gateway of the physical machine 6. Start the virtual machine and configure a static IP. Except for the host segment of the IP address, I configured 131 here. The other configurations are consistent with the physical host. Save after configuration 7. Restart the network card and try to ping Baidu. If it works, you can surf the Internet.The above is the detailed content of Static IP connects to the external network in NAT mode in centos. For more information, please follow other related articles on the PHP Chinese website!