How to set static ip in Ubuntu 21.04?

The default configuration /etc/netplan/00-installer-config.yaml

# This is the network config written by 'subiquity'
network:
  ethernets:
    ens160:
      dhcp4: true
  version: 2

I tried to modify the configuration

network:
  ethernets:
    eth0:
      dhcp4: no
    eth1:
      dhcp4: no
      addresses: [192.168.0.7/24]
      gateway4: 192.168.0.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]

Ip address is not binding


Your original file had the network interface as ens160, you changed it to eth0, does eth0 actually exist on your system?. Check the actual device names you are using match the devices in your system. The output of ifconfig -a will show the actual device names.