Host-only routing issues

Discussions related to using VirtualBox on Linux hosts.
Post Reply
450AHX
Posts: 5
Joined: 22. Jun 2016, 09:04

Host-only routing issues

Post by 450AHX »

Hi.

My host is a Debian server connected to the public network, to my LAN (just a single cable between two NICs), and running a wireless AP. Additionally, it runs an OpenVPN server with a few clients. My guests are a couple Debian VMs.
I want the guests to be able to listen for and make connections to my LAN and the VPN.

Bridging the virtual NICs to the LAN NIC does everything I want, even the host DHCP works. The problem is that the virtual NICs replicate the state of the physical NIC, so if my PC at the other end of the cable is offline, all of the VMs disconnect. Ideally, I would like something like this; I would like for the network to behave as if the VMs, the server, and my PC were all connected to the same switch.
Since I couldn't figure out how to do that, my idea then was to use the VMs with host-only networking and add the corresponding routing rules to the server. My understanding is that this behaves like adding another NIC to the host and connecting all the VMs to a virtual switch. I can't get this to work at all.

My host has several addresses for my networks: 10.x.0.1, with x depending on the specific network. vboxnet0 is configured as 10.3.0.1. Pinging from the guest to 10.3.0.1 works fine, but I can't reach it by any other address, nor can I reach any other node. Ping returns "network is unreachable" immediately. I'm guessing this means that the guest is not using the host as a gateway, so it's not even attempting to send the ping request. However, I don't have any way to configure that in the DHCP options dialog for vboxnet0.
Any ideas?

Thanks.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Host-only routing issues

Post by Perryg »

Host-only means exactly what it says. It allow communications between the host and the guest. It sounds like you really need to use bridged but you should read chapter 6 of the manual.
450AHX
Posts: 5
Joined: 22. Jun 2016, 09:04

Re: Host-only routing issues

Post by 450AHX »

Okay, which part in particular? A cursory scan doesn't tell anything I don't already know.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Host-only routing issues

Post by Perryg »

The link explains what the various adapters really do. Like I said it appears you need to use bridged. I can tell you that the host-only was not designed to do anything near what it appears you want. There is no gateway defined and the default subnet while it can be changed will not be in one you will need. Adding a subnet to the host-only that is within your local lan will cause a conflict.
450AHX
Posts: 5
Joined: 22. Jun 2016, 09:04

Re: Host-only routing issues

Post by 450AHX »

So how do I keep the virtual NIC from replicating the state of the physical NIC? Like I said, bridged does everything I want, but it only works as long as my desktop is running.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Host-only routing issues

Post by Perryg »

I am not sure what you are really wanting to do, but I can tell you that all guest virtual networking is dependant on the host. You could try USB networking direct in the guest if you want to remove the host network, but your host would still need to be running or the guest will not.
450AHX
Posts: 5
Joined: 22. Jun 2016, 09:04

Re: Host-only routing issues

Post by 450AHX »

Maybe I'm not making myself clear.

My VM host is a Debian server with three NICs: an on-board NIC connected to a Windows desktop, a PCI NIC connected to the Internet, and a PCI wireless NIC serving as access point. Additionally, there's a VPN tunnel with a few clients connected remotely.
If I bridge the virtual NIC to the on-board NIC, everything work fine; the VM can even be reached through the VPN. But this is only as long as the Windows desktop is running. If the desktop is turned off, the virtual NIC is disconnected.
I need the VM to be reachable by clients on the VPN even when only the Internet connection and the VPN running through it are up.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Host-only routing issues

Post by Perryg »

My VM host is a Debian server with three NICs: an on-board NIC connected to a Windows desktop
Makes no sense to me. In any case if the host is connected then all guests are dependant to the host. If the host looses its connection because as you say it is disconnected from a Windows desktop which does not make sense to me either, is it just another guest?
450AHX
Posts: 5
Joined: 22. Jun 2016, 09:04

Re: Host-only routing issues

Post by 450AHX »

The Debian server is running on a motherboard with an on-board Ethernet card (eth1). There is an Ethernet cable connected to this card. The opposite end of this cable is connected to another on-board Ethernet card, on a different computer's motherboard. This other computer is my Windows desktop.

The VM's interface (let's call it veth0) is bridged to eth1. When the desktop is turned on, both eth1 and veth0 are UP, and the VM is reachable by the VPN. When the desktop is turned off, both eth1 and veth0 are DOWN, and the VM is not reachable by the VPN.

I need veth0 to be always UP and reachable by the VPN, even when eth1 is DOWN. When eth1 is UP, the VM should also be reachable by the desktop. I can understand if this is not doable by bridging. Any other method is fine, as long as it does what I need.

I don't know how to make it any clearer.
Martin
Volunteer
Posts: 2562
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: Host-only routing issues

Post by Martin »

Buy a small Ethernet switch and put it between your server and desktop ;)
Post Reply