6

I have configured two VMs with Oracle Linux 8 on VirtualBox. Each VM:

  • Adapter 1: NAT, each has connectivity to the internet
  • Adapter 2: Host only adapter, Which doesn't shows a IP address!

Each configured with the same Hhost only adapter DHCP server.

DHCP server settings #1: DHCP server settings #1

DHCP server settings #2: DHCP server settings #2

  • Host only adapter interface is enp0s8
  • Nat interface is enp0s3

enp0s8 interface (host only adapter)

What am I missing here? Why does interface enp0s8 has no IP addres and why doesn’t the manual IP assignment work?

3
  • I think this is an old bug in VirtualBox. Try to exchange the adapters, so Adapter 1 is the Host Only.
    – harrymc
    Commented May 17, 2022 at 19:36
  • @harrymc , Well I tried to do so , But then I didn't had an IP address for my Adapter 2 , which is the NAT interface , so I didn't had internet connectivity. Very strange... Thanks Commented May 18, 2022 at 20:05
  • If the DHCP of the host-only network isn't working, static IPs might be the solution. Try perhaps to reinstall VB, hopping you're using the latest version.
    – harrymc
    Commented May 18, 2022 at 20:31

3 Answers 3

2

There's been ongoing discussion on the answer posted by John. But I didn't find those answers/discussions working towards a plausible resolution. May be I missed something? But surely I read tons of articles/posts by now.

So here's my answer which should resolve the issue of the main question relating to assigning IP address while using Host Only Network Adapter.

Context

When I spin-up a virtual machine with a Host Only Network Adapter by default, the VM doesn't get an IP on an interface called enp0s8. This interface is valid for Debian 10. But, I am able to see an IP is assigned to enp0s3 interface. Yes, all the preceding comments are correct mentioning IP does not get assigned! However, the idea of assigning a VM to a Host Only Adapter is to be able to communicate to this new VM from host machine. And since, there's no IP assigned to this VM, host machine simply will not be able to connect to it.

Resolution

For Debian/Ubuntu OS, you need to edit this file /etc/network/interface.

Then update the file with below contents. Note, there are 4 spaces for address and netmask directives.

auto enp0s8 allow-hotplug enp0s8
iface enp0s8 inet static
   address 192.168.56.11
   netmask 255.255.255.0

Please note, I set up static instead of dhcp. This we should be able to assign a static IP to a particular VM. Now, perform restart on the VM.

Test

Do a ping test from host machine with VM static IP: 192.168.56.11. You should be able to ping success result. As such, you should be able to connect to this VM using SSH login as well i.e., ssh [email protected]. Use the username and password of your VM OS.

Hope this helps someone!

1
  • 1
    thanks a lot. After a few hours of trying, this is what worked for me Commented Dec 9, 2022 at 11:29
2

Simply, request a new IP from DHCP server:

sudo dhclient -1 enp0s8
1

Virtualbox host only adapter interface doesn't get an IP

That is entirely normal.

A Host Only Adapter is isolated and does not include Internet. The Host Only machine should be able to communicate with the Physical Host Machine, and then would have an IP on the Host Machine.

Change the Host Only Adapter to NAT if you wish it to have Internet Access.

To avoid confusion, here is a decent article on connecting a Host Only VM to a Host machine

Connect a Host Only VM to Host

Create the Virtual Network First, you must set up a virtual network that the host-only adapter(s) will communicate through.

In the VirtualBox window, click File > Host Network Manager > Create. Check Enable under the DHCP Server column of the network you just created. Select your network and click Properties. In the Adapter Tab, select Configure Adapter Manually and use the following settings: IPv4 Address: 192.168.56.1 IPv4 Network Mask: 255.255.255.0

In the DHCP Server Tab, make sure that Enable Server box is checked, and use the following settings: Server Address: 192.168.56.100 Server Mask: 255.255.255.0 Lower Address Bound: 192.168.56.3 Upper Address Bound: 192.168.56.254

Click Apply and then Close Add a Host-Only Adapter to the Guest Machine For each guest you want to communicate with using the network from the previous step, you need to add a host-only adapter.

Select the appropriate guest machine Click Settings > Network Under the Adapter 2 tab, input the following settings: Enable Network Adapter: Checked Attached to: Host-Only Adapter Name: vboxnet0 (NOTE: this should be the name of the network you created in the previous steps)

Click OK

8
  • 1
    Having an IP address is not related to having Internet access. VirtualBox has a built-in DHCP server which is supposed to issue IP addresses to VM guests in this case. Commented May 17, 2022 at 18:48
  • This is not correct , the VM should have been assigned a ip address from the DHCP pool. I have tried it on another VM before and It did assigned me an IP address , But this time I am not sure what I'm missing. Thanks anyway Commented May 18, 2022 at 20:00
  • A Host Only VM does not have Internet access, and only talks to its host. So it should not be part of a general DHCP pool. That would defeat the purpose of a Host Only machine
    – anon
    Commented May 18, 2022 at 20:21
  • I amended my answer to illustrate how to connect an isolated Host Only VM to its host
    – anon
    Commented May 18, 2022 at 22:19
  • DHCP pool does not required to be an Internet feature , It's a network feature. Anyway , How would you recommend to setup a VM with a internet connection and with a connection to other VMs. Thanks Commented May 20, 2022 at 8:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .