What is Netplan?
Ubuntu 18.04 LTS ships with Netplan as a network management tool
by default. Netplan allows simpler and declarative configuration of networks and
interfaces with YML files, which eases both human and machine configuration.. Netplan
Network Manager to apply the desired configuration.
Netplan configuration files are stored in
/etc/netplan/*.yaml. The default one created
by the Ubuntu installer is stored at
editing this file is sufficent, though you can create others.
TODO: Confirm it’s safe to edit 50-cloud-init.yaml, this is not yet clear to me.
By default, the configuration file looks like this (given two interfaces called
network: ethernets: enp1s0: addresses:  dhcp4: true enp2s0: addresses:  dhcp4: true optional: true version: 2
To set a static IP, set the options as found below, ensuring you set
dhcp4: false, and
nameservers : addresses. There are also
additional options available under the
network: ethernets: enp1s0: dhcp4: false addresses: [192.168.1.2/24] gateway4: 192.168.1.1 nameservers: addresses: [22.214.171.124,126.96.36.199] enp2s0: addresses:  dhcp4: true optional: true version: 2
Finally, to apply, run:
sudo netplan apply
Or, if you encounter an error and need to debug:
sudo netplan --debug generate