VirtualBox: two network interfaces (NAT and host-only ones) in a Debian guest on Ubuntu
The solution was pretty simple: I just had to add the following lines in Debian virtual machine's /etc/network/interfaces
file:
allow-hotplug eth1
iface eth1 inet dhcp
The second line instructs the interface to obtain an IP via DHCP. The first line loads the interface at boot time.
To apply the changes to a running system, invoke:
ifup eth1
The name for the eth1
interface may vary, use ifconfig -a
to list all available interfaces.
EDIT: full /etc/network/interfaces
:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
allow-hotplug eth1
iface eth1 inet dhcp
I was facing similar problem with my Ubuntu 14.04 VM, and Solution suggested by @brandizzi for Debian worked with little change.
EDIT: file /etc/network/interfaces:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet dhcp
For UBUNTU 16.04
Run command
ifconfig -a
Look for new interface like in my case it is 'enp0s8'
EDIT file /etc/network/interfaces:
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s3
iface enp0s3 inet dhcp
auto enp0s8
iface enp0s8 inet dhcp
In Ubuntu 18.04 host, VirtualBox 6.1, using Ubuntu 19.04 as guest
In the guest edit /etc/netplan/50-cloud-init.yaml
file, add two lines as shown below (before the version line). Looks like the network configuration in the guest is set up only to handle one network and the second one has to be added manually
network:
ethernets:
enp0s3:
dhcp4: true
enp0s8:
dhcp4: true
version: 2