The current syntax to replace gateway4
is routes
with to
and via
.
For the netplan above based on the 192.168.10.0/24
network, it would be:
routes:
- to: default
via: 192.168.10.1
So the whole config would be:
network:
version: 2
renderer: networkd
ethernets:
eno1:
dhcp4: false
dhcp6: false
addresses:
- 192.168.10.10/24
routes:
- to: default
via: 192.168.10.1
nameservers:
addresses: [192.168.10.1]
Currently there's a very good reference full of practical examples at:
https://netplan.io/examples/
One other tip when working on netplan files, yamllint
can save you a lot of trouble.
sudo apt install yamllint
sudo dnf install yamllint
sudo pacman -S yamllint
For example, I introduced a small formatting error:
- to: default
via: 192.168.10.1
Then when I run yamllint
, I'll get a line number that should help track down where the errors are.
yamllint /etc/netplan/01-netplan.yaml
28:9 error syntax error: expected <block end>, but found '?' (syntax)
If you have any syntax errors (for example spacing issues) yamllint will give you the line numbers of your problems.
Hopefully this has made your netplan generate
and netplan apply
go smoothly!
sudo netplan generate
sudo netplan --debug apply