Internet hosts access web servers under virtual machines

Source: Internet
Author: User

The Internet host previously installed LAMP on the Centos Virtual Machine to access the web server under the Virtual Machine and set up its own web server. For detailed procedures, see the blog post: Ghost
In addition to the questions written in the previous blog post, I would like to try to access the web server on the Virtual Machine by using the ip + port of the local machine, I can deploy my web server as a server that can access the internet. First, let's talk about my environment: Host: System win7, IP address 172.18.186.210 virtual machine version is VMware Workstation 7, the Centos operating system is installed under the virtual machine, the IP address is 192.168.202.128, and LAMP is deployed to become a web server www.2cto.com
Network Environment: Campus Network (with authenticated servers, requiring account authentication to access the internet). virtual machines are connected to the Internet through NAT in the campus network environment, other hosts on the campus network can be considered as hosts on the Internet. In fact, the use of NAT network for virtual machines reminds us of the knowledge of computer networks. We can regard our host as a router, and then the virtual machine is a host in a LAN, the IP address of a port on the shared router is used to access the Internet. To access the host from the Internet, you need to map the port on the router. So what we need to do is to map a port of the host to the ip address of the Virtual Machine on VMware. To access the virtual machine from the Internet, just enter the ip address of the local machine: port to access the virtual machine. First, set the Virtual Machine network:
Select edit --> edit VPC, as shown in:

Get the following settings window (because the network connection mode of NAT uses the VMnet8 Nic, we edit this Nic and click "VMnet8 "):

As you can see, my VM is in the network segment 192.168.202.0. Click NAT Settings (as shown in the above red box) and the following page is displayed:

Click "Add" in the red box to set the ing between the host port and the virtual machine ip address and port, after you click Add, the following setting page is displayed: www.2cto.com

I have mapped port 5901 of the host to port 80 of "192.168.202.128" of the VM. Because the web service automatically opens port 80, as long as we access "http: // 172.18.186.210: 5901, you can access port 80 of the virtual machine, that is, the web service. If you build a web server based on my previous blog posts, you can access the index. php "file (that is, a php file under the newly created web server/var/www/html, /var/www/html/is the default web page program directory of the web server ). In fact, the NAT Internet access and port ing under virtual machines are very simple and easy to operate. Of course, there are many virtual network mechanisms, which are encapsulated well and transparent to users, it seems very intelligent. There are also bridging and other ways to access the Internet. In the face of different applications, they all have their unique advantages and deserve our in-depth study. Prepared by AI_Net

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.