Host Only VLAN

This is for discussing general topics about how to use VirtualBox.
Post Reply
N0YB
Posts: 36
Joined: 20. Sep 2012, 18:55

Host Only VLAN

Post by N0YB »

Is it possible to have a host-only adapter as a VLAN of a bridged adapter?

Want the client to have only one "physical" NIC and using a VLAN for connection to a host-only adapter network. While at the same time using the "native" (non VLAN) for connection to the bridged adapter network.

Host is Windows 8.1 Pro
Guest is FreeBSD
BillG
Volunteer
Posts: 5102
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Host Only VLAN

Post by BillG »

It would be better if you simply explained what you want to do. All networks which a vm can see are virtual, so VLAN doesn't really have much meaning.

A host only connection can only see the host. That is why it is called host only. You can certainly have a network of one or more vms and connect that network to the physical network using only one physical NIC in the host.
Bill
N0YB
Posts: 36
Joined: 20. Sep 2012, 18:55

Re: Host Only VLAN

Post by N0YB »

Don't know if I can explain adequately or not but I'll try.

In a physical environment it would be like this:

FreeBSD:
em0 (native, no vlan), 192.168.2.2
em0.1 (VLAN 1), 192.168.149.2

A dedicated management client on VLAN 1


In VirtualBox it would be like this:

Host-only adapter:
VLAN 1: 192.168.149.1

FreeBSD (VM client):
Adapter 1:
Bridged Adapter:
Native: 192.168.2.2
VLAN 1: 192.168.149.2

So the VM client, using the bridged adapter, communicates with 192.168.2 natively (no vlan) as it normally would,
and communicates with 192.168.149 (host only network) via VLAN 1 (the host as being the dedicated management client).

EDIT:
Trying to mimic a physical setup in which the physical interface also has a VLAN assigned and need the host and VM communication to be over that VLAN.
BillG
Volunteer
Posts: 5102
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Host Only VLAN

Post by BillG »

And have you tried it? I would think that a host only network would work in the same way without change. The guest will normally use the bridged adapter, but traffic between host and guest would use the host only adapter. If you want to prevent the host and guest from communicating through the LAN (in other words, force them to only use this path only) you would need to take extra steps. But that would be so in both cases.

In both cases you are in fact using two different interfaces in each machine (host and guest) connected to two different networks.
Bill
N0YB
Posts: 36
Joined: 20. Sep 2012, 18:55

Re: Host Only VLAN

Post by N0YB »

Yes, have tried. Configuring the guest is straight forward. Just add the VLAN to it's network config. But how to create a host interface to be in that VLAN?

EDIT:
LAN <--> windows host <--> VM brigded adapter <-|-> em0   - 192.168.2.2   (native)
                                                |-> em0.1 - 192.168.149.2 (vlan 1)
That part is straight forward and easy.

But how to create a host only within that same vlan 1?
BillG
Volunteer
Posts: 5102
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Host Only VLAN

Post by BillG »

Forget about VLANs. That is irrelevant. Just use host only. By default it will not use the 192.168.149 subnet but that is irrelevant as well. Also forget about em0.1 .There is no such thing and is not necessary. Just use em1 and set it to host only. You are trying to make it all more complicated than it needs to be.

It would be much easier to do between two guest vms rather than between host and guest. You could then use an internal virtual network instead of host only as your "VLAN".
Bill
N0YB
Posts: 36
Joined: 20. Sep 2012, 18:55

Re: Host Only VLAN

Post by N0YB »

Bill, I know how to do that, and in fact have already done that. However that is exactly what I don't want to do though.

Want to be able to set it up the same as the physical environment it is intended to mimic. Which means a VLAN, not another "physical" interface (em1, etc).

Yes there is such a thing as em0.1. It's VLAN 1 on em0. Need the host to be on VLAN 1 too.
BillG
Volunteer
Posts: 5102
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Host Only VLAN

Post by BillG »

This really has nothing at all to do with VirtualBox. It is purely a networking problem. There is no point in being too literal if you are trying to emulate a network scheme. There is no point in going through the process if you insist on doing it exactly the same way. That is a duplication, not an emulation.

VLANs are simply an way to use multiple networks with a single adapter. You can do all the same things with multiple networks and multiple adapters (as you had to do before VLANs were invented). It does not change the way things actually work or the result.
Bill
Post Reply