Set static IP in linux

determine the name of your network interface

ip a

make a backup of the netplan configuration

sudo cp /etc/netplan/01-network-manager-all.yaml /etc/netplan/01-network-manager-all.yaml.backup

edit the config file

sudo vim.tiny /etc/netplan/01-network-manager-all.yaml

make the following changes, replacing “interface_name” with the intended interface

network:
  version: 2
  renderer: networkd
  ethernets:
    interface_name:
      addresses:
        - 192.168.1.101/24
      nameservers:
        addresses: [8.8.8.8]
      routes:
        - to: default
          via: 192.168.1.1

try the new configuration

sudo netplan try

If all is good, press ENTER