After you create a ubuntu 20 virtual machine, it will automatically discover and config the default network interface.
The problem is that, after we add a new network interface to it, the new interface will not be activated automatically and cannot be used immediately.
We will show you how to activate the new interface in the following example.
In the virtual machine's terminal, execute the following command, and you will see all your interfaces.
ip a
Most interfaces have an ip address, the one without an ip address is probably your new interface.
In my own environment, lo
and ens33
both have an ip address, but ens38
does not have one. So, ens38
is the name of the new interface.
Open file /etc/netplan/00-installer-config.yaml
, and you will see something like:
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
dhcp4: true
version: 2
It's a yaml file and contains all the activated interfaces. Here we already have the default interface ens33
in ethernets
section.
After we add the new interface ens38
to it, /etc/netplan/00-installer-config.yaml
will be like:
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
dhcp4: true
ens38:
dhcp4: true
version: 2
After we change the config file, execute the following command to take effect:
sudo netplan apply
On older version of ubuntu, the config file's path is /etc/network/interfaces
and it has a different file format, do not use it. On Ubuntu20, we should use /etc/netplan/00-installer-config.yaml
.