CentOS----Host Unable to access Web services solution in virtual machine

Source: Internet
Author: User

The host cannot access the Web service in the virtual machine

The CentOS6.5 operating system is installed in the VMware virtual machine in the Windows7 host, and a Web server is built based on Nginx, and the Web page in the virtual machine can be accessed through the host's browser when the Web page is just set up. But after a while, can not access, this problem has troubled himself for several days, each had to go through the virtual machine snapshot back to just set up a good web service that step, so you can access, but after a while can not access.

Later through the Internet to find information, finally understand, is a CentOS6.5 firewall does not open the Web service 80 port, shielding the external access. There are two ways that a host can access a virtual machine's Web page: (1) Shut down the firewall in the virtual machine, and (2) Open the 80 port of the Web service.

1. Turn off the firewall

Use

Service Iptables Stop

command to temporarily turn off the firewall so that the Web pages in the virtual machine can be accessed through the host.

iptables firewall is usually boot-up, using the above command to temporarily shut down the firewall, the next time the boot or the firewall software, you can use the following command to prohibit booting the firewall:

Chkconfig iptables off

However, the purpose of the firewall is to prevent external malicious access, so it is best to keep the firewall running.

2. Turn on the Port 2.1 command line mode to open 80 port

Use the following command to temporarily open port 80:

/sbin/iptables-i input-p TCP--dport 80-j ACCEPT

Restart the firewall to take effect:

Service Iptables Restart

If you want to keep port 80 open at the next boot, save the current settings using the following command:

Service Iptables Save

2.2 Modify the Iptables configuration file to open the port

Use

Vim/etc/sysconfig/iptables

command to modify the iptables firewall configuration file and add a line of content as follows:
-A input-p tcp-m state--state new-m TCP--dport 80-j ACCEPT


Then restart the firewall:

Service Iptables Restart

This makes it possible to access the virtual machine's network service through the host.

CentOS----Host Unable to access Web services solution in virtual machine

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.