Ubuntu – NetPlan Static IP address not acceptiing

17.10ipnetplanserver

Trying to setup Static IP and it will not work.

IP address 192.168.100.40

pre 17.10 and netplan config as follows

auto ens160
iface ens160 inet static
address 192.168.100.45
netmask 255.255.252.0
network 192.168.100.0
broadcst 192.168.103.255
gateway 192.168.100.1
dns-nameservers 192.168.100.1

Run sudo netplan ifupdown-migrate

And get ens160: method static is not supported

Try to use this netplan config and it errors out

network:
  version: 2
  renderer: networkd
  ethernets:
    ens160:
        dhcp4: no
            addresses: [192.168.100.40/22]
            gateway4: 192.168.100.1
            nameservers:
            addresses: [8.8.8.8,8.8.4.4]

add dhhcp6: yes and still errors out via netplan debug

What am I missing?

Best Answer

Please try:

network:
  version: 2
  renderer: networkd
  ethernets:
    ens160:
      dhcp4: no
      dhcp6: yes
      addresses: [192.168.100.40/24]
      gateway4: 192.168.100.1
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]

In other words, /24 instead of /22 and correct the spacing and indentation. Follow with:

sudo netplan apply

Please post any warnings or errors.