Set Static IP on Ubuntu 20.04

Create or edit /etc/netplan/01-netcfg.yaml and insert the below, replacing the adapter name and IP info if required:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses: [10.0.0.2/24]
      gateway4: 10.0.0.1
      nameservers:
        addresses: [1.1.1.1,1.0.0.1]

The example above sets a static IP on my Raspberry Pi.

To restart networking, you can then run sudo netplan apply.

About

I'm a technology professional who's been passionate about computers since my Grandad introduced me to an Intel 386 back in the 90s when I was a kid. Those moments inspired a passion within for technology, and I've been playing around with anything with a circuit board ever since. Whenever I have a moment you can probably find me working on something computer-related, and this is where I like to write about those moments.