5

After reading this post, I've followed this answer. But , when I edit the /etc/netplan/01-netcfg.yaml, it was blank. So I create that file and add optional: true. After sudo netplan apply, It turns out to be an error error in network definition unknown key 'optional'.

Is the previous post answer still relevant for ubuntu 20.04? And he stated that:

Don't mask or disable the systemd service.

So, what is the best solution for this in 20.04?

edit:
result of ls /etc/netplan

00-installer-config.yaml  01-netcfg.yaml

result of cat /etc/netplan/01-netcfg.yaml

optional: true

result of sudo lshw -C network as @heynnema requested as @heynnema requested and result of cat /etc/netplan/*.yaml
enter image description here

1 Answers1

5

In /etc/netplan:

sudo rm -i /etc/netplan/01-netcfg.yaml # remove unnecessary file

sudo -H gedit /etc/netplan/00-installer-config.yaml # edit this file with these contents:

For dhcp:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: true
      optional: true

For static IP: (bridged network)

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      addresses:
        - 192.168.x.xxx/24
      gateway4: 192.168.x.1
      nameservers:
        search: [mydomain, otherdomain]
        addresses: [8.8.8.8, 8.8.4.4]
      optional: true

Create /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

sudo -H gedit /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

with the following content:

network: {config: disabled}

Then:

sudo netplan generate

sudo netplan apply

reboot

heynnema
  • 73,649