This article does not introduce information about Virtual box, CentOS, Apache installation, mainly for post-installation related configuration, so that the host can access the client machine (Guest:centos in Virtual box) to provide Web services.
- Virtual Box Network settings
many articles on the internet say to use Host access to Guest 's Web service requires two networks (NAT and Hostonly), in fact we only need to use a NAT network to achieve the purpose.
take NIC 1 as an example , Select " network address Translation (NAT)" In the connection mode, and set the promiscuous to " deny ";
Simple to use NAT does not allow the Host to access Guest directly , it needs to set the port mapping,
As shown , we map some ports of host to the guest, such as the 80 port that we are asking for CentOS when we visit http://127.0.0.1:80.
- Configuration of CentOS
when the port mapping is set , the Web service provided by the guest is not opened when the http://127.0.0.1:80 is accessed through the browser, but the guest is properly connected via SSH.
through netstat-tlpn to view the port information for CentOS:
Although there is a listening port , but only for TCP6 (IP6), and TCP (IP4) and the end of listening to the port, so when using a browser connection does not open the Web service normally.
You can open ports with the following command and allow iptable4s access :
iptables-i input-p tcp-m tcp--dport 80-j ACCEPT
or
Iptables-i input-i eth1-p tcp-m tcp--dport 80-j ACCEPT
and use Service Iptables Save Save the configuration .
Use The Internet Explorer accesses Apache in CentOS as shown below :
- Resources
set iptable4s and open the appropriate port :
Http://serverfault.com/questions/324190/virtualbox-and-centos-6-cannot-connect-to-httpd
To install the iptables4 service :
Http://stackoverflow.com/questions/24756240/how-can-i-use-iptables-on-centos-7
Virtual Box + CentOS Minimal + Apache build Web server