VMware Workstation configuration NAT under Linux host set port mapping-ubuntu as an example

Source: Internet
Author: User

Recently toss the virtual machine, because it is under the Linux, and the relative information is relatively small, so encountered some problems.

One is to configure the NAT settings for VMware Workstation. As a general rule, Nat can share the host's IP, so as to be able to access the Internet as a host, do not need to configure IP for the virtual machine separately, in addition, the VMware Workstation in the NAT settings can be port forwarding, so after the addition of port mapping, It is easy to access the resources of a virtual machine through one of the host's ports. I think it is very practical and convenient. So configure the virtual machine to prefer NAT mode. I am configuring a Linux virtual machine on a Linux host.

Related Paths

One is the NAT profile path for VMware Workstation on the host, typically located at:

1 /etc/vmware/vmnet8/nat/nat.conf

The other is the network address profile path in Linux, typically located in:

1 /etc/network/interfaces
Configure virtual machine IP

Here, you first configure the virtual machine's IP address. Of course, before configuring the gateway and subnet mask for NAT, this VMware comes with a tool: Vmware-netcfg, located under the VMware installation folder. The default should be in/usr/lib/vmware/bin/vmware-netcfg. To open with Super User privileges:

1 sudo/usr/lib/vmware/bin/vmware-netcfg


You can see that the default NAT configuration of the virtual NIC is Vmnet8, which has its gateway and other information, because I want to use a static IP configuration, so I canceled the automatic assignment of DHCP. Of course, these can be changed.

Once you know this information, you can configure the IP address in the virtual machine, the corresponding file is located in the

1 /etc/network/interfaces

The default first two lines are the configuration of the loopback address, generally without changes, for the following configuration of the static IP, the specified gateway, the subnet mask, and the DNS name server. For example, my configuration is

1234567891011 # The loopback network interfaceauto loiface lo inet loopback# The primary network interfaceauto eth0iface eth0 inet staticaddress 192.168.198.10netmask 255.255.255.0gateway 192.168.198.2dns-nameservers 192.168.198.2

This completes the configuration and restarts the virtual machine's network service

1 sudo/etc/init.d/networkingrestart

At this time test, you should be able to access the network.

Configure NAT Port mappings

Virtual machines can access the extranet, then the external network is required to access the virtual machine's resources. For example, I set up an HTTP server on the virtual machine, located on port 80 of the virtual machine, if I want to map to the 100080 port of the host. This is the time to edit the VMware NAT configuration file directly. The gadget above is not enough.

1 sudovim /etc/vmware/vmnet8/nat/nat.conf

Open the configuration file and you can see a profile. Of course, other options for this file can also be edited as appropriate, and port mappings are primarily

123456789101112 [incomingtcp]# Use these with care - anyone can enter into your VM through these...# The format and example are as follows:#<external port number> = <VM‘s IP address>:<VM‘s port number>#8080 = 172.16.3.128:8010080=192.168.198.10:80 [incomingudp]# UDP port forwarding example#6000 = 172.16.3.0:6001

There are already examples in the comments, such as the virtual machine HTTP port I want to map to port 10080 on the host, and because the HTTP protocol is based on the TCP protocol, add a line to the INCOMINGTCP:

1 10080=192.168.198.10:80

When you are finished editing, save and restart the VMware service:

1 sudoservice vmware restart

The configuration is complete. If the 80 port service in the virtual machine is turned on, you can see the resource contents of the corresponding virtual machine by accessing localhost:10080

VMware Workstation configuration NAT under Linux host set port mapping-ubuntu as an example

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.