In some tutorials (Here and Here) about netplan dhcp4 appear in the following way:

 version: 2
 renderer: networkd
    dhcp4: no


    dhcp4: yes

But in netplan examples and blog ubuntu sometimes appear in the following way:

    dhcp4: true


    dhcp4: false

And in other examples it appears as not/yes

What is the correct way to set dhcp in Ubuntu 18.04 (yes/no or true/false)? Thanks


Netplan configuration syntax is YAML, and the dhcp4 setting takes a boolean value.

According to http://yaml.org/type/bool.html the acceptable values are y/n, yes/no, true/false and on/off, written either with all lowercase, with an Initial Capital, or with ALL CAPS.

So all of the ways you listed are correct.

The canonical ("the most correct" if a distinction must be made) form would be lower-case y/n.

However, the definition says:

A Boolean represents a true/false value. Booleans are formatted as English words (“true”/“false”, “yes”/“no” or “on”/“off”) for readability and may be abbreviated as a single character “y”/“n” or “Y”/“N”.

So you can use any of those forms, whichever you find easiest to read.

  • Thank you for this reference. I was confused while reading over the documentation examples on netplan.io -- they should simply pick a convention to avoid unnecessary confusion among those not familiar with YAML (yet). – bd1251252 Mar 27 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.