tips
21 tips Netplan
One command, setting or habit at a time about Netplan: what it does, the line to copy and a caveat or two.
Netplan 18
-
With two network cards on different subnets, source-based rules keep the replies on the right card.
- to: 192.168.3.0/24 -
Netplan's hidden key changes how the SSID is scanned, so networks that do not broadcast their name can be joined.
hidden: true -
Only used in 802.3ad mode, lacp-rate chooses between a slow 30 second and a fast one second LACP interval.
lacp-rate: fast -
Without the key netplan enables only IPv6 link-local addresses, and an empty list switches both kinds off.
link-local: [] -
Switches Wake on LAN on for an interface, which the docs say to match by MAC.
wakeonlan: true -
Stops other local users from reading secrets stored in your network config.
ls -l /etc/netplan/ -
A network port that is often down no longer holds up the startup.
optional: true -
Rename an interface by its MAC address so the config keeps pointing at it.
ip -br link -
Combine two ports so the second takes over when the first link drops.
mode: active-backup -
Hand network settings back to you on images where cloud-init manages them.
echo 'network: {config: disabled}' | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg -
Prints the live state of every network interface, with addresses, routes and DNS.
netplan status -
Applies a netplan change and automatically undoes it unless you confirm it in time.
sudo netplan try -
Prints the live network state of the interfaces and can compare it with your YAML.
netplan status -
Adds a tagged VLAN interface on top of a physical port in netplan.
network: {version: 2, ethernets: {enp3s0: {}}, vlans: {vlan20: {id: 20, link: enp3s0, addresses: [10.20.0.5/24]}}} -
Builds a bridge in netplan and gives the address to the bridge.
network: {version: 2, ethernets: {enp3s0: {}}, bridges: {br0: {interfaces: [enp3s0], dhcp4: true}}} -
Sets a fixed address and default route the current way in netplan.
network: {version: 2, ethernets: {enp3s0: {addresses: [192.168.1.20/24], routes: [{to: default, via: 192.168.1.1}], nameservers: {addresses: [192.168.1.1]}}}} -
Writes one key to the netplan configuration without opening an editor.
sudo netplan set ethernets.enp3s0.dhcp4=false -
Shows the final merged netplan configuration, or a single part of it.
sudo netplan get
Network and DNS 3
-
Fix a reserved address that your router never hands to an Ubuntu server.
dhcp-identifier: mac -
Keeps the DHCP address but replaces the DNS servers with your own.
network: {version: 2, ethernets: {enp3s0: {dhcp4: true, dhcp4-overrides: {use-dns: false}, nameservers: {addresses: [192.168.1.2]}}}} -
Parses the netplan YAML and reports errors without changing the network.
sudo netplan generate
Nothing in this filter yet.