Ubuntu on virtualbox no internet connection

Trying to access the internet on a virtualbox VM with Ubuntu-20.04.1 LTS and a WiFi adapter.

The VM has 2 network adapters. NAT and host only with a host-only adapter with static IP address.

The netplan config looks like:

network:
  ethernets:
    enp0s3:
            dhcp4: yes
    enp0s8:
            addresses: [192.168.56.3/24]
            gateway4: 192.168.56.1
            nameservers:
                    addresses: [4.2.2.2, 8.8.8.8]
  version: 2

and ip addr show says:

2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:dd:a6:04 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 86264sec preferred_lft 86264sec
    inet6 fe80::a00:27ff:fedd:a604/64 scope link
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:0e:27:7d brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.3/24 brd 192.168.56.255 scope global enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe0e:277d/64 scope link
       valid_lft forever preferred_lft forever

enp0s3 is assigned a 10.x.x.x address but still it doesn't work, whereas another VM which gets the same 10.x.x.x address does work.

What am I missing?


Solution 1:

Probably, it is an issue with the default route. You don't need the Gateway and DNS for host-only network!

You may check it using: ip route show

Remove them from the configuration, so default Gateway goes to interface with NAT/DHCP configuration. Also DNS which does not seems to affect, but keep reasonable clean configuration.