I’m using Virtualbox 4.3.30 and I’ve successfully set a virtual machine up with a host-only network to work on DHCP with a non-static IP, but of course, for a virtual machine server, it’s essentially useless. So now, I’m trying to set up a virtual machine Linux server with access to the internet, and a host-only static IP. Host is Windows 8.1, guest is Ubuntu server.

VM config

I have two network devices, one for NAT, and one host-only set to adapter #3. The NAT allows for access to the internet which works. The host-only adapter doesn’t allow the host to access the virtual machine.

VirtualBox config

Host-only adapter #3 has DHCP disabled, an IP of, and a netmask of

The VM system

After running:

sudo ifconfig eth1 netmask up

…(from here then ifconfig reveals that eth1 (host-only) is connected to the IP address. On the virtual machine, if I do wget it pulls down the default Nginx page on itself. From the host I’m able to ping the static IP address however in the browser, the IP address times out with the message Unable to connect.

Stuff I've tried!

I have also tried editing /etc/network/interfaces from here to no success.

What’s happening here? I’m guessing it can’t be a firewall issue as the host connects when the host-only is using DHCP and I can successfully ping from the host. It also looks like the browser's "cannot connect message" appears in the browser faster than a simple timeout.


I think I've hit on a bug - if I activate the DHCP in the network only adapter, and set the lower and upper to the same ip address, it seems the browser can all of a sudden allow the network to occur and succeeds.

  • Please edit your question: What is your host OS? Also it might help if you could post the actual configuration of /etc/network/interface as well as the actual output of ifconfig. – Giacomo1968 Oct 9 '15 at 16:38
  • Host os is specified, I've excluded any config for eth1 (host-only) from /etc/network/interface as that will only make it permanent, the eth1 up code is in the question though, and the relevant line from ifconfig is inet addr: Bcast Mask – user3791372 Oct 9 '15 at 16:40
  • What is your host OS? Linux? I understand the guest OS is Linux, but I am still unclear. “It also looks like the cannot connect message appears in the browser faster than a simple timeout.” Fairly irrelevant point. Your web browser is not doing anything more unique than ping. Both items mean the host is not reachable. – Giacomo1968 Oct 9 '15 at 16:45
  • Seriously, read the last line of the first paragraph. And like I wrote, ping can successfully ping the guest, but the browser can't reach it, though Nginx is up and succesfully running. – user3791372 Oct 9 '15 at 16:48
  • Okay, then this is an Nginx issue. Are you sure the Nginx config is set for networking and not just localhost connections? But I still feel your IP address settings might be a bigger factor here. Please read my latest edit to my answer. – Giacomo1968 Oct 9 '15 at 16:59

You state that you set the following:

sudo ifconfig eth1 netmask up

From all of my experience using VirtualBox, the guest OS works on a network in the 192.168.56.x range. So I would recommend using this command instead:

sudo ifconfig eth1 netmask up

As for why I am choosing—instead of—in your comment to this answer you stated:

No, I can’t use 192.268.56.x as the default DHCP usually works within that range so will cause conflicts.

Well, the thing is with a netmask of nothing but the last octet of the address will ever be passed to the larger network on the host. That’s what a netmask is. Further, if you look under “Preferences -> Network” from the VirtualBox application itself and then look under “Host-only Networks”, select that network—should be vboxnet0—and then click the edit icon and look under the DHCP server settings you will find these DHCP server settings:

  • Server Address:
  • Server Mask:
  • Lower Address Bound:
  • Upper Address Bound:

Note that DHCP is not taking up the whole range of IPs in 192.168.56.x; it simply starts at for the DHCP server itself and then goes from to Which means IPs in the range of to are free for static use. Note that I left out since that is the VirtualBox router IP address that connects the host OS to the guest OS.

And then to make the change permanent, add a network interface to /etc/network/interfaces like this. Open up the /etc/network/interfaces file:

sudo nano /etc/network/interfaces

And then when all that is tested, done and working as expected you can add—or adjust—the interface details like this:

# The local hostmachine access interface.
auto eth1
iface eth1 inet static
  • No, I can't use 192.268.56.xxx as the default DHCP usually works within that range so will cause conflicts, and this is no different to what I already have. – user3791372 Oct 9 '15 at 16:45
  • 1
    @user3791372 Check my edit to the answer. DHCP is not the full 192.268.56.x range. And the netmask will not allow you to set a subnet other than something in the 192.268.56.x range. Just use an IP from to for a static address and there is no conflict. – Giacomo1968 Oct 9 '15 at 16:56
  • Nope, not working – user3791372 Oct 9 '15 at 17:25
  • Ping responds, on the host, ipconfig shows the network adapter and the correct ip address, on the guest, eth1 is showing the correct inet address, but it's as if windows doesn't connect the virtualbox adapter to the actual machine (so it responds to pings, but nothing else) – user3791372 Oct 9 '15 at 18:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.