networking - Network access virtualbox linux guest from linux host

25
2013-09
  • winchendonsprings

    I've tried countless settings, read Virtualbox forums and googled for more hours than I'd like to admit.

    What I want to accomplish is simply to be able to ssh into the guest and be able to view websites hosted on the guest. I do not care how I access the guest, whether its a bridged connection, host-only, NAT with port forwarding or anything else.

    So what I need to know

    Within Virtulabox manager > Preferences > Network > vboxnet0

    --What should my 'Adapter' and, if needed, 'DHCP Server' settings be? An example of this would be great.

    Within Virtualbox machine > Settings > Network

    --What should I have for Settings? Specifically 'Attached to' 'Name' 'Adapter type' 'Promiscuous mode' 'Port Forwarding'

    Or if you can link me to a solution that I may not have seen/tried already it would be greatly appreciated.

  • Answers
  • Kenster

    You probably have the VMs set up with NAT adapters to give them access to your host's network connection. You can't communicate between the host and the guest using the NAT adapter. You have to set up a host-only network and add a a host-only network adapter to the VM. The host and guest can communicate through this network, and two VMs can also communicate with each other.

    1. As you said, go to Virtualbox manager > File > Preferences > Network and set up a host-only network. Enable the DHCP server. In my case, the host adapter address is 192.168.56.1, the DHCP server address is 192.168.56.100, both masks are 255.255.255.0, and the server address range is 192.168.56.101-192.168.56.254, but I believe these were all filled in by Virtualbox as defaults.
    2. After setting up this network, you should see a virtual interface on your host system with the correct IP address (the one assigned to the adapter).
    3. Now, go to network settings for the VM. Add a new network adapter. Set "attached to" to the "host-only adapter", and the name to the host-only network that you set up earlier.
    4. Start the VM. It should see the host-only adapter in addition to whatever adapters it was using before. If it's a modern operating system, it'll probably query the DHCP server and set up the interface on its own.

    You can assign a host-only adapter to the VM in addition to a NAT adapter. I have a windows VM and an Ubuntu Linux VM set up this way. Both VMs have no trouble communicating with each other as well as the Internet.


  • Related Question

    windows - how to access samba on a guest Linux behind the VirtualBox NAT?
  • noamtm

    On my laptop, I'm running Ubuntu 9.10 under WinXP using VirtualBox 3.1.2. I want a setup where:

    1. The guest can freely access the internet.
    2. The host can access the guest files via Samba.
    3. The setup must work whether or not my ethernet/wifi ports are connected.

    Is it possible?

    #1 works with NAT and bridged networking.

    #2 works with bridged and host-only networking.

    Bridge-based setup doesn't work if relevant physical port is not connected. At the office, the laptop is connected to wifi or ethernet. At home, wifi only.

    Is there a workaround? Am I missing anything? I hope I'm making my question clear.


  • Related Answers
  • heavyd

    I would try setting up two separate network adapters.

    • Adapter #1 would be your current #1 setup: NAT to allow access to the internet available.
    • Adapter #2 would be a host-only setup to provide the connection between the host and the guest for the Samba shares.
  • Eight_Quarter_Bit

    Another possibility is to create two bridged virtual NICs, one to the physical wireless interface and one to the physical wired interface. As long as one (or both) of the physical interfaces is connected you should have access. I generally try to avoid NATing as much as possible, since it tends to create a lot of headaches in the long run (as you have seen with file sharing).