Page 1 of 1

Can't access host from guest

Posted: 7. Apr 2016, 00:19
by kkroo
I have two interfaces on vm, the NAT on 10.0.2.0/24 and a Host only on 192.168.40.0/24

The host has IPs 10.0.2.2 and 192.168.40.1

I can have the host listen on some random port 5555 and can telnet from the guest to 10.0.2.2

When I try to access port 5555 using the 192.168.40.1 address, it doesn't work. Is this intentional? Is there any way to set up a way to have the guest connect to an actual (virtual ok too) network interface on the host? This would work if the NAT network showed up as a network interface on the host, but apparently it doesn't.


Thanks!

Re: Can't access host from guest

Posted: 8. Apr 2016, 12:44
by Elizine
Did you setup networking as below?

Setup the virtualbox to use 2 adapters:
  • The first adapter is set to NAT (that will give you the internet connection).
  • The second adapter is set to host only.
  • Start the virtual machine and assign a static IP for the second adapter in Ubuntu (for instance 192.168.56.56). The host Windows will have 192.168.56.1 as IP for the internal network (VirtualBox Host-Only Network is the name in network connections in Windows). What this will give you is being able to access the apache server on ubuntu, from windows, by going to 192.168.56.56. Also, Ubuntu will have internet access, since the first adapter (set to NAT) will take care of that.
  • Now, to make the connection available both ways (accessing the windows host from the ubuntu guest) there's still one more step to be performed. Windows will automatically add the virtualbox host-only network to the list of public networks and that cannot be changed. This entails that the firewall will prevent proper access.
To overcome this and not make any security breaches in your setup:
  • Go to the windows firewall section, in control panel.
  • Click on advanced settings. In the page that pops up
  • Click on inbound rules (left column), then on new rule (right column). Chose custom rule, set the rule to allow all programs, and any protocol. For the scope, add in the first box (local IP addresses) 192.168.56.1, and in the second box (remote IP) 192.168.56.56.
  • Click next, select allow the connection, next, check all profiles, next, give it a name and save.