A
A
at0m1x2019-08-15 14:26:03
virtual box
at0m1x, 2019-08-15 14:26:03

Ubuntu Server 18.04 + VirtualBox - How to set up a network?

Available:
Ubuntu Server 18.04.3 LTS

$ sudo ls /etc/netplan/
01-network.yaml         50-cloud-init.yaml.bak
$ sudo cat /etc/netplan/01-network.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: yes
    enp0s8:
      addresses: [192.168.56.2/24]
      gateway4: 192.168.56.1
      dhcp4: no

$ sudo cat /etc/netplan/50-cloud-init.yaml.bak
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    ethernets:
        enp0s3:
            dhcp4: true

$ sudo cat /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
network: {config: disabled}

$ sudo ifconfig -a
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::a00:27ff:fe0e:f506  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:0e:f5:06  txqueuelen 1000  (Ethernet)
        RX packets 2  bytes 1180 (1.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 15  bytes 1704 (1.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.2  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::a00:27ff:febe:a750  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:be:a7:50  txqueuelen 1000  (Ethernet)
        RX packets 508  bytes 47165 (47.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 462  bytes 53569 (53.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 6  bytes 402 (402.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 402 (402.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

At the same time, ping google.com does not work from the guest OS; no internet access at all.
But there is access from the main OS to the guest, for example, when connecting via SSH.
If you remove the section for enp0s8 in the /etc/netplan/01-network.yaml config, and leave only the section for enp0s3, then the situation will change exactly the opposite: there will be Internet access from the guest OS, but not from the main OS to the guest.
What mistake is made here, why, with the above configs, there is no Internet access from the guest OS, and access to the guest OS from the main OS at the same time?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
ranebull, 2019-08-15
@ranebull

In what modes are 2 network interfaces in VirtualBox for this virtual machine?
ping 8.8.8.8in guest OS too returns nothing?
What IP do you use to connect from the host OS to the guest OS?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question