Setting up the network in VMware NAT mode

Source: Internet
Author: User

One, virtual machine NAT mode principle

Nat mode is also called VMnet8 under VMware. In this mode, the host has two network cards, a real physical network card (that is, NAT device), connected to network; a VMware network Adapter VMnet8 that communicates with the virtual machine NIC through a virtual switch (VMNET8).

Because NAT device has the network address translation function, the data of the virtual Machine network card is forwarded through the VMware network Adapter VMnet8, and after the address translation, the real physical network card is forwarded to the network. In addition, in NAT mode, the host computer is the equivalent of a DHCP-enabled router, and the virtual machine is a real host in the intranet, and the router (host computer) DHCP dynamically obtain network parameters. Therefore, in NAT mode, the virtual machine can access the external network, and vice versa [1] (Note: If we do a NAT setting under VMware, you can access the virtual machine from the external network, as described below).

The virtual machine NAT mode principle is as follows:

"Noun explanation"
Vmnet8:vmware is used for Virtual switch under virtual NAT network;
VMware Network Adapter VMnet8: This is the virtual network card used by host hosts to communicate with the NAT virtual network;

Second, the software version

Virtual machines: VMware? Workstation Pro
Linux:centos 6.5
Terminal emulation software: Xshell 5

Third, the NAT mode realizes the virtual machine to the external network access function

1. Under the System menu, select "Virtual Machine", "Settings", network adapter Select "Custom": VMnet8 (NAT mode).

2. Under the System menu, select "Edit", "Virtual Network Editor", Press to configure. Note: We do not start the DHCP service here, so the next step is to manually configure the virtual machine with a static IP configuration. If you check the "Use local DHCP service to assign IP addresses to virtual machines", it means to start the DHCP service, then we do not need to make a static IP configuration of the virtual machine, as long as the dynamic acquisition of IP is good.
Here the virtual machine IP is located in the subnet segment: 192.168.81.0/24.

Also click on "Nat Settings" to view the virtual machine gateway address:

3, find the host's "Control Panel", "Network and Internet" and "Network Connection", double-click "VMware network Adapter VMnet8", the host intranet IP settings.

The main purpose of this step is to place the host and the virtual machine in the same network segment, so the IP address is set to any IP within the virtual machine network segment, but it is important to prevent IP address collisions, and the gateway is set to the IP address provided by the VMware NAT network shot. Since VMware is a 81 segment in My Computer, and 192.168.81.2 (virtual machine gateway IP) 192.168.81.0 (subnet IP) has been occupied, all I changed my host to 192.168.81.1, that is, in 192.168.81 this network segment, 192.168.81.1 is my host (host), then I in the virtual machine When installing the operating system, you can set their IP address to: 192.168.81.3 .... 192.168.1.255

Configure the Linux system network:

Enter the virtual machine operating system:

Edit the network configuration file for Linux

Change the value of onboot in the red box from No to Yes to enable the network: Change the value of Bootproto from DHCP to static to use a static IP

The value in the green box adds itself: The first green Arrow indicates that the current operating system's IP (this IP setting, which is already marked by red text, does not conflict), and the second green Arrow indicates that the network segment, using the NAT gateway provided by VMware, is already noted.

Use the command to restart the network (restart the network is not possible, you may need to restart the network card, depending on the system version of the kernel different, generally do not need this step)

At this time, your host and virtual machine are already in the same network segment (I am here 81 network segment). This time can ping www.baidu.com can ping the instructions, the virtual machine connected to the Internet, of course, the premise is that the host can surf the Internet, if the host is not networked, you can ping the host IP (note is the virtual machine network segment IP, I here is 81 network segment)

Four, the NAT mode to implement the external network to the virtual machine (SSH) Access function

Host and virtual machine in the same network segment, the host can not directly SSH to connect the virtual machine, but also need to do a step port mapping

1. Under the VMware System menu, select Edit:, enter the virtual network editor, and select NAT settings.

After you enter NAT settings, under Port forwarding, select the Add button to add a NAT mapping rule. Where the host port is the port of the host physical network card, you can fill in the port number, because we are here to implement SSH Telnet function, here fill in "22". The virtual machine IP address is 192.168.81.3 (the Linux I just installed, the IP set is 192.168.81.3), and the virtual machine port must be 22 (because the external device eventually accesses the SSH service of the virtual machine via Port 22).

When the add is complete, the port forwarding adds a record:

If you have multiple virtual machines in VMware and several require SSH connections to the host, then you need to have several port forwarding.

After the configuration number, you can use SSH to connect to the virtual machine, but there are a few caveats, 1. Whether the virtual machine has openssh,2 installed. Check to see if the firewall for the virtual machine is turned on.

If you do not have the above two cases can ssh virtual machine!

Setting up the network in VMware NAT mode

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.