Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Short Description:

My host OS is Ubuntu-12.04 and using VirtualBox I have set up a VM of Oracle Linux 6.4 (based on RHEL) with Apache httpd webserver. I need to access the web pages served by the VM from my host Ubuntu.

================================================================================

Additional Details:

Here are the configurations:

  • The 1st network adapter of the VM is configured as NAT, since I need it to use the host's Internet connection. See image below:

NAT configuration of 1st adapter

  • I have enabled a 2nd adapter as Host-only, so I can access the VM from the host (ssh or scp to guest VM from host, etc). This is working fine. The IP of the guest VM is manually set to 10.10.10.15 and I can successfully ping, ssh and scp to the guest VM without any problem. See below:

Host-only configuration of 2nd adapter

Inside the VM, I have setup Apache successfully and it's working for localhost but when I try to access the page from the host, by entering 10.10.10.15 in Chromium or Firefox, it fails to connect! :(

I have also tried to add an entry inside /etc/hosts as follows, but entering test-website.net inside Chromium or Firefox still gives the same error! :(

10.10.10.15    test-website.net

One more thing to note is about SELinux. As you might know, SELinux is enabled by default on RHEL-based distros such as CentOS and Oracle-Linux. To make sure that SELinux is not messing up my work, I have configured it to permissive mode in /etc/selinux/config and confirming the effect after reboot using sestatus:

SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   permissive
Mode from config file:          permissive
Policy version:                 26
Policy from config file:        targeted

================================================================================

This may sound like a duplicate of the following questions, but the answers in these questions suggest to setup a Host-only adapter for the guest and configure /etc/hosts in the host, which I have already tested and didn't work for me:

Any help ?!

share|improve this question
    
If you run wget 10.10.10.15 in the host, what error does it display? –  ignis Jul 16 '13 at 15:06
    
@ignis Here is the output for wget 10.10.10.15 : Connecting to 10.10.10.15:80... failed: No route to host. –  Seyed Mohammad Jul 17 '13 at 0:20
add comment

2 Answers

up vote 1 down vote accepted

I figured out what was causing the problem ... iptables!

The configuration I have set up for the VM should work without any problem.

If anyone with the same setup is facing problems, checkout the following:

  • System firewall (i.e. iptables) configuration;
  • SELinux configuration;

cheers :)

share|improve this answer
1  
To manually turn off iptables in the guest: sudo service iptables stop –  Randy Fay Oct 2 '13 at 15:54
add comment

Did you bind apache to all interfaces or just lo?

BTW: You don't have to use a 2nd network (host only) so as to access the guest services.

By using NAT port forwarding, you can set up rules to map web and ssh/sftp/ftp ports so that you can access those by accessing localhost:PORT on the host.

For example to map guest ssh to host port 2222, you can access it by ssh -p 2222 user@localhost

VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"

NOTE: Forwarding host ports < 1024 impossible, it is a NAT limitation.

share|improve this answer
    
Actually I didn't do anything special after installing Apache with YUM, other than starting the httpd service. What should I do ? –  Seyed Mohammad Jul 17 '13 at 0:33
    
yum... that is CentOS/RHEL, this is for Ubuntu/Debian, wrong place... –  Terry Wang Jul 17 '13 at 2:19
    
I did mention in the question that the VM is Oracle Linux which is based on RHEL ... Can you please explain your note on binding Apache to all interfaces ... What exactly should I do to fix my problem? –  Seyed Mohammad Jul 17 '13 at 7:47
    
In your site's configuration file, what did you bind to? e.g. <VirtualHost *:80> –  Terry Wang Jul 17 '13 at 21:49
    
I haven't done any binding. Actually I don't need the server to be accessed by a name. The VM's IP address (i.e. 10.10.10.15) is fine if it works ... –  Seyed Mohammad Jul 17 '13 at 22:19
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.