Configuring Static IP with Netplan on Ubuntu
Below you will find the steps to configure a static IP address with Netplan on Ubuntu. The netplan config files are located at /etc/netplan and the default configuration file is /etc/netplan/01-netcfg.yaml
Open the network config file with an editor such as nano:
sudo nano /etc/netplan/01-netcfg.yaml
Netplan uses Python for it's configuration syntax so it's important that all line indentation is correct.
In the example below, we'll be using a static IP address of 172.16.253.200 on the first network interface ens33 and a gateway IP of 172.16.253.1. This configuration uses CloudFlare DNS in conjunction with Google DNS.
Once all your changes have been made, you can apply them by running:
sudo netplan apply
Configuring a DHCP address with Netplan
If you'd like to configure your Ubuntu server to run on DHCP (on both ipv4 and ipv6) instead of a static IP address, see the configuration below.
This file describes the network interfaces available on your system
For more information, see netplan(5).
Don't forget to run the command to apply the changes after you're done