Access to the Web service in the virtual machine

Source: Internet
Author: User
Tags ssh secure shell

Often found that if we want to get a little gadget or run some small demo, always have to constantly in their work on the computer to build a different operating environment, over time, the books are flooded with various software, speed down, and management is also very inconvenient. So the idea of using virtual machines to build a running environment, one can build different environments, two can be isolated from each other. The next step is to access the virtual machine service in the host:

Preparation environment:

1, the virtual machine installed CentOS, virtual machine using NAT way

2, install the Tomcat service in CentOS, through Ifconfig the IP address is, can ping in Windows and use SSH Secure Shell The client can also connect to the CentOS in the virtual machine

3, External System is win7

4, Virtual machine address:, host address:

Issue one: The Web server in the virtual machine cannot be accessed through on the host


1. Switch to the root user

2. Enter the following two commands within the terminal


Iptables-p INPUT ACCEPT (set default Allow rule)

3. Set up a Linux firewall

Add in/etc/sysconfig/iptables-A rh-firewall-1-input-m State--state new-m tcp-p TCP--dport8080-j ACCEPT

Issue two: The Web server in the virtual machine cannot be accessed through on the host


Set up VMware, port mapping pair, to open 8080 port, VMware's edit->virtual networkeditor->nat (select VMnet8)->edit-> Add mapping host Port:8080,virtualmachine IP address:,port:8080 in portforwarding

Access to the Web service in the virtual machine

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: 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.