How a Linux virtual machine can access the Internet in a virtual machine when it is in NAT mode

Source: Internet
Author: User
Tags uuid

First, the question:
1, if set to NAT mode, the default DHCP dynamic acquisition IP address, the system will generate/ETC/SYSCONFIG/NETWORK-CONFIGS/IFCFG-ENS33 by default, the file content is as follows:
   
  
  1. DEFROUTE="yes"
  2. IPV4_FAILURE_FATAL="no"
  3. IPV6INIT="yes"
  4. IPV6_AUTOCONF="yes"
  5. IPV6_DEFROUTE="yes"
  6. IPV6_FAILURE_FATAL="no"
  7. NAME="ens33"
  8. UUID="ece1577e-e492-4d3c-84a2-ddccb3019424"
  9. ONBOOT="yes"
  10. IEEE_8021X_EAP_METHODS="MD5"
  11. IEEE_8021X_IDENTITY="[email protected]"
  12. IEEE_8021X_PASSWORD_FLAGS="user"
  13. HWADDR="00:0c:29:44:47:5c"
  14. PEERDNS="yes"
  15. PEERROUTES="yes"
  16. IPV6_PEERDNS="yes"
  17. IPV6_PEERROUTES="yes"
  18. BOOTPROTO="dhcp"
2. Change DHCP to static IP address 3, no Internet access
 
    
   
  1. [[email protected] network-scripts]# ping www.sohu.com
  2. ping: unknown host www.sohu.com
Second, the settlement:
1, configure the virtual machine NAT environment, Edit menu->virtual Network Editor:
Subnet IP set to 192.168.130.0
Subnet Mask set to 255.255.255.0

set in NAT settings:
set the gateway IP to 192.168.130.2

set in DHCP settings:
to configure the range of IP pools: 192.168.130.50~192.168.130.254

2. Configure the host VMware Network adapter VMnet8 :

Note:
The
default gateway must be 192.168.130.0, which is consistent with the subnet of the virtual machine
DNS is not set

3, configure the virtual machine Fedora /etc/sysconfig/network-configs/ifcfg-ens33, the deletion of partial configuration, increase the DNS configuration:
   
  
  1. TYPE="Ethernet"
  2. DEFROUTE="yes"
  3. IPV4_FAILURE_FATAL="no"
  4. NAME="ens33"
  5. UUID="707084bc-d3aa-483f-878b-c93e6abf4a07"
  6. ONBOOT="yes"
  7. #HWADDR="00:0C:29:8B:9A:F2"
  8. HWADDR="00:0c:29:94:8e:a2"
  9. BOOTPROTO="static"
  10. NM_CONTROLLED="yes"
  11. IPADDR="192.168.130.101"
  12. NETMASK="255.255.255.0"
  13. GATEWAY="192.168.130.2"
  14. DNS1="192.168.1.1"
Attention:
DNS1 must be the same as the DNS of the host to remove the configuration other than the above configuration (other configurations may affect manual configuration items), otherwise you will still be unable to access the Internet
4. Test whether Internet access is available



From for notes (Wiz)

How a Linux virtual machine can access the Internet in a virtual machine when it is in NAT mode

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.