I'm trying to create a Virtualbox VM (running Ubuntu Server 22.10) which has NAT (for internet access) and host-only adapter with static IP. It seems that I can get only one of both working. Optimally I'd configure the whole setup with automation tools like vagrant
and ansible
, but for now I am using netplan
to debug directly in the VM.
(I'm new to networking, so any additional explanations are welcome.)
If I netplan apply
only the NAT configuration:
# This is the network config written by 'subiquity'
network:
ethernets:
enp0s3:
dhcp4: true
version: 2
I get normal internet access. Results of route -n
are:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.2.2 0.0.0.0 UG 100 0 0 enp0s3
10.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3
10.0.2.2 0.0.0.0 255.255.255.255 UH 100 0 0 enp0s3
10.0.2.3 0.0.0.0 255.255.255.255 UH 100 0 0 enp0s3
If I also apply the host-only configuration:
network:
version: 2
renderer: networkd
ethernets:
enp0s8:
addresses:
- 192.168.56.11/24
I lose internet access (ping -c 1 google.com
results in Network is unreachable
, as well as other commands like curl something
or sudo apt update
). Output from route -n
:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.2.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3
192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s8
I notice the difference, but I'm not able to interpret it in a useful way.