Create your netplan file
vi /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
ens3:
dhcp4: no
addresses: [192.50.1.157/24]
gateway4: 192.50.1.1
nameservers:
addresses: [8.8.4.4,8.8.8.8]
Check our file to see if it is correct:
sudo netplan try
if you have an error in the file it will tell you.
Eg. formatting is important if you have the below you will get an error because all of the options under ens3n
/etc/netplan/01-netcfg.yaml:9:13: Error in network definition: expected mapping (check indentation)
ens3:
^
Notice that under ens3 below that there is no indentation of dhcp4, addresses etc.. and that is incorrect (whereas the old interfaces file didn't care)
network:
version: 2
renderer: networkd
ethernets:
ens3:
dhcp4: no
addresses: [192.50.1.157/24]
gateway4: 192.50.1.1
nameservers:
addresses: [8.8.4.4,8.8.8.8]
apply the new plan once try above succeeds (it means it will apply the network settings in the yaml file you created)
sudo netplan apply
debian, netplancreate, netplan, vi, etc, netcfg, yaml, renderer, networkd, ethernets, ens, dhcp, addresses, gateway, nameservers, sudo, eg, formatting, definition, mapping, indentation, incorrect, whereas, interfaces, didn, succeeds, settings,