Ubuntu 18.04 LTS and later versions use Netplan for managing the network configuration.
Netplan configuration are driven by .yaml files located in /etc/netplan directory.
Please note that yaml files use spaces for indentation.
If you use tab or incorrect indention, your changes won’t be saved.
network:
version: 2
renderer: networkd
ethernets:
enp0s25:
dhcp4: no
addresses:
- 192.168.1.16/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
sudo netplan apply
more info: https://netplan.io/examples/