brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: netplan set changes one YAML key from the command line

Netplan
~/tips/tip-netplan-set-single-key

sudo netplan set ethernets.enp3s0.dhcp4=false

Writes one key to the netplan configuration without opening an editor.

For a quick change I do not need an editor. netplan can write a value into the configuration for me.

sudo netplan set ethernets.enp3s0.dhcp4=false
sudo netplan set 'ethernets.enp3s0.addresses=[192.168.1.20/24]'

The argument is a dotted path, an equals sign and a YAML value, so lists need square brackets and quotes. The change is written to a YAML file in /etc/netplan, and --origin-hint picks the file name: --origin-hint 70-netplan-set gives /etc/netplan/70-netplan-set.yaml. Nothing is applied: run netplan try next. Keep a copy of the folder if you want an easy way back.

Further reading: netplan set

More Netplan tips – to: 192.168.3.0/24 hidden: true lacp-rate: fast link-local: [] wakeonlan: true All Netplan tips (21) All topics

Link