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: a static IP in netplan sets the default route under routes instead of gateway4

Netplan
~/tips/tip-netplan-static-ip-routes-default

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]}}}}

Sets a fixed address and default route the current way in netplan.

Older guides still show gateway4. Recent netplan versions mark that key as deprecated and print a warning.

# /etc/netplan/60-static.yaml
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]}}}}

The default route is a normal entry in routes, which also takes extra routes such as to: 10.20.0.0/16. The compact flow style above is valid YAML. A normal block layout works as well and is easier to read in a long file. Only one default route can exist per address family and routing table. Try the file with sudo netplan try before you rely on it.

Further reading: Netplan YAML configuration reference

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