Mutual access to the virtual machine and the host virtual machine to access the Internet

Introduction: When setting up the virtual machine, when accessing the network encountered some problems, Novice always toss some, a little collate it, and make a conclusion.

Background: install a virtual machine, install Centos7 system (installation steps do not introduced)

1, the installation CentOS, network connection is optional NAT

 

2, the virtual machine settings a bit, network

3. After obtaining this information, want to achieve each boot IP will not change, so it is necessary to set a static IP IP

命令:vim /etc/sysconfig/network-scripts/ifcfg-ens33

Change the network card configuration: vim / etc / sysconfig / network-scripts / ifcfg-ens33

Modify the inside: BOOTPROTO = "static"

In the final note add content :( added content here, and your set-top gateway to the virtual machine, IP compatible)

        IPADDR=XXX.XXX.XXX.XXX

                            NETMASK=255.255.255.0

                            GATEWAY=XXX.XXX.XX.XX

Service network restart - restart the Network Services

 Such a static IP setting is finished

This time it can ping IP debugging to see if the host can access centos

 

4, I want to access the Internet: curl www.baidu.com - test to look at can not return the correct information

If you can not access, set about vim /etc/resolv.conf

 The /etc/resolv.conf Detailed : https://www.cnblogs.com/Alight/p/4351155.html

Add Content:

  nameserver: DNS Address 1

  nameserver: DNS address 2 (optional, if not the first access will automatically access the second)

Restart the network, test again to see if you can access the Internet:

6.OK. Success friends

 

Guess you like

Origin www.cnblogs.com/yimihua-kai/p/11029078.html