Ubuntu Server Static Network with Netplan

Since Ubuntu 17.10 Artful, ifupdown has been replaced with Netplan. After each session trying to remember how to configure Netplan I seem to forget the locations and syntax. So this is for my aging memory. The configuration files for Netplan live in:

/etc/netplan/

The default install of Ubuntu 18.04 leaves the following file:

/etc/netplan/50-cloud-init.yaml

As you can see the config file is in yaml. Unless specified manually the default install will give a simple file using DHCP. However for a static IP address customise the following:

network:
    ethernets:
        ens33:
            addresses:
             - 192.168.176.10/24
            gateway4: 192.168.176.2
            nameservers:
             addresses: [1.1.1.1,8.8.8.8]
    version: 2

If you have any issues with your yaml configuration file then you can use the following to see what is going on:

sudo netplan --debug apply

Which should give you something like, which in this case is successful:

Netplan has many useful features rolled up in a structured configuration file. For more info check out the following links:

Netplan reference

Netplan configuration examples

Netplan