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
.