# Host-only network in VirtualBox

## Spiros

I'd like to have a virtual machine connected to a host-only network. I have virtualbox-4.0.22 installed (but I also tried with virtualbox-bin-4.0.22).

The problem is that, even after loading vboxdrv, vboxnetadp and vboxnetflt, ifconfig -a does not show the virtual adapter and the virtual machine network settings page does not let me choose any host-only adapter.

Is it possible that my kernel configuration must be corrected? Or is somebody aware of a possible solution?

----------

## gentoo_ram

I don't see the VM network adapter show up until I actually start a VM.

----------

## Spiros

gentoo_ram: then you can actually start a VM. I can't! I cannot even set up the machine to use the host-only adapter because VirtualBox does not find any.

EDIT: sorry, I was unclear. I CAN start VMs, but not with an host-only adapter.

----------

## gentoo_ram

Let's step back second.  I think you have to set up the host-only adapters first.  On the Virtualbox UI, go to File -> Preferences.  Under there is a tab for "Network".  On that tab is an icon to add an adapter.  Click on that and configure the host-only adapter first.  

After that's done, you should be able to select it on the VM configuration.

What I just described is how it works in VB 4.2.0.  It's probably similar in older versions, the main preferences panel may look slightly different than what I described.

Does that help get you going?

I run my VMs all sharing the same host-only network.  Then I set up iptables Internet sharing just like you would if sharing an internal LAN adapter.  I like this set up better than bridging.  Gives me more control over the network behavior.  This method works well if you have a lot of experience messing with iptables rules.

----------

## Spiros

Thanks for your accurate description, gentoo_ram! Unfortunately, this does not help.

Now I upgraded to virtualbox-4.2.0-r1 and I have the same behaviour. I explain it a bit more in detail.

I go into the configuraton of the machine and select the page "Network". Then, I select the adatpter 2 (the first one is still NAT and I let it so). I enable the adapter 2 and I select "Attached to:" "Host-only adapter". Now the box "Name" is active and the only option is "Not selected". The button "OK" is inactive and the warning box says "no host-only network adapter is selected". The snapshot shows this situation.

The modules vboxdrv, vboxnetadp and vboxnetflt are loaded correctly. dmesg does not list anything relevant:

```

$ dmesg | grep vbox

[    3.558991] vboxdrv: Found 8 processor cores.

[    3.559146] vboxdrv: fAsync=0 offMin=0x188 offMax=0x13ed1

[    3.559171] vboxdrv: TSC mode is 'synchronous', kernel timer mode is 'normal'.

[    3.559172] vboxdrv: Successfully loaded version 4.2.0 (interface 0x001a0004).

[ 2524.521446] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 2542.899274] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 2554.942854] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 2555.307155] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 2562.926773] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 2563.297208] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 3550.383563] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 3550.991374] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4101.752682] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4101.765078] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4101.790470] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4101.816026] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4101.841303] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4101.869864] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4101.896071] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4101.924615] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4101.950762] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4102.228122] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4102.257751] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4102.301566] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4102.327383] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4102.352570] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4102.378934] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4966.525184] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 4967.010218] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 5451.316850] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 5702.648679] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 6198.323816] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 6198.365012] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 6198.390657] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

[ 6198.415984] Modules linked in: vboxnetadp(O) vboxnetflt(O) vboxdrv(O) hid_logitech_dj nvidia(PO)

```

My first guess was that something was not set up correctly in the kernel, but in this case the modules would say something, wouldn't they?

EDIT: I also have a laptop with a very similar configuration and the same problem: I cannot set up a Host-only adapter because there are no such adapters.

----------

## dreeh

did someone found a solution?

my workaround for that issus is, to start the adapter by hand:

ifconfig vboxnet0 192.168.50.1 netmask 255.255.255.0 up

but this doesnt start automaticly. this was always working with an older version of virtualbox.

----------

## Spiros

I did not find a solution. I just checked and I don't have a vboxnet0 interface in ifconfig -a, even if the module vboxnetadp is loaded.

----------

## liucougar

here is a workaround:

https://forums.gentoo.org/viewtopic-t-943758-start-0.html

----------

## Spiros

Thanks for the link, liucougar. Unfortunately, I don't think this is my case, because I just do not have any vboxnet interface. In my opinion what I need is a kernel module. Anyway, I don't use VirtualBox anymore, so I can't test this workaround.

EDIT: I don't know how, I don't know why, I don't know when, but the problem just disappeared. Now I have working host-only networks. Thanks all.

----------

