How can I bring down the interface in the netplan configuration?

I have an Ubuntu server 18.04 and simple netplan configuration (see below):

---
network:
  ethernets:
    ens1:
      dhcp4: false
      addresses:
      - "192.168.99.1/24"
    ens2:
      dhcp4: false
      addresses:
      - "172.20.0.82/23"
      gateway4: "172.20.0.1"
      nameservers:
        addresses:
        - "172.20.0.62"
  renderer: "networkd"
  version: 2

If I run the command: "ip link set dev ens1 down" so the corresponding interface has status "down". If then I run the command "netplan apply" so this interface brings up. How can I change netplan configuration (without committing and lines deleting) in order to have bring down and specified in netplan configuration interfaces not brought up?


Solution 1:

There is presently no support for defining interface configuration in netplan without netplan apply also bringing those interfaces up. This is a longstanding feature request which required systemd work before it could be implemented. The work is tracked at https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/1664844.

Note that the tasks for Ubuntu bionic have been marked "wontfix"; so this will only be available in netplan in Ubuntu 20.04 and later.