Writing a new answer as so many are just wrong.
Do not edit
00-installer-config.yaml or ANY system generated files/package files.
From https://netplan.io/examples/ :
"To configure netplan, save configuration files under /etc/netplan/ with a .yaml extension (e.g. /etc/netplan/config.yaml) .."
The installer/system did that. Now you need to override it.
man netplan-generate for the rules governing how the network configurations are read from
/etc/netplan/*.yaml (and elsewhere).
To correctly update the netplan area to use a static IP over the default DHCP:
Edit/Create a new file (the prepended number+dash and .yaml extension are important):
sudo nano /etc/netplan/99-custom-network.yaml
Add your properly formatted YAML to this file. A static IP example:
(Note: My network device is
ens160 - not
eth0 - adjust as needed.)
Then do a
sudo netplan apply.
Make sure your network interface looks right and is working (
ip ad /
Then do a reboot. Retest.
This follows the netplan.io instructions as well as the general rule of not editing any existing/installed files when possible. In
/etc/netplan/ and similar conf.d/ type config areas you should always opt for a high numbered custom/new file (if possible) instead of editing any installed package files.
It's why they have numbered files in these configuration areas (in /etc/netplan/ and others). The higher the number on the file equates to when it is read in.
Therefore, something with "99-" prepended on it will generally be read in last and OVERRIDE anything that repeated before it. Therefore, if a network interface is set to DHCP in "00-installer-config.yaml", and/or "50-cloud.init.yaml", the settings for the same interface in a "99-*.yaml" file will override everything else read in previously.
Generally these installed YAML files will NOT get overwritten, but that isn't valid logic to not follow the conf.d "standard" of using custom files to override and avoid editing any installed files. It doesn't take any extra time. Drop a file in netplan. Done. So, there's no excuse as I have witnessed in comments of "well, it's worked so far..".
So, editing the default netplan *.yaml(s) will technically (usually) "work", but you should avoid using them when possible.