0

I am using Ubuntu 18 minimal image to create an Ubuntu server with VirtualBox. I created a host only network and added adapter to vm along with NAT adapter (already configured).

The original configuration of netplan was the following:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: yes

I changed this configuration to the following to enable host only adapter (enp0s8):

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: ye
    enp0s8:
      dhcp4: no
      addresses: [192.168.56.101/24]
      gateway4: 192.168.56.1

Now I am successfully able to access the VM from the host machine over the network. But internet inside the VM stops working :(. I have tried so many different solutions but either I get internet working (provided by NAT adapter) by disabling host only adapter, or can access vm from host by enabling host only adapter.

I suspect the VM is trying to connect to internet via host only adapter. How can I change this?

  • Delete the host-only adapter. Host-only is NOT a useful answer for your use case. Your problem is how to create a network connection from host to guest using NAT. – user535733 Sep 21 at 19:26
  • If one wants to access samba or something which hard to assign destination port, host-only adapter is still very useful. – Alvin Liang Nov 8 at 3:40
1

I am also hitting the same issue. I am able to get it work by removing this line:

      gateway4: 192.168.56.1

There are other alternatives discussed in netplan configuration on Ubuntu 17.04 virtual machine, however what I need is just to set up a lab environment for testing, so I didn't try those out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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