Netplan files are short, but YAML is strict about indentation, and the way you set a default gateway changed in Ubuntu 22.04. One wrong space and the network doesn’t come up. The generator below writes the file for you.
Why use a generator
- No syntax errors – indentation and lists are always correct
- Right syntax for your release –
routes:on 22.04+ andgateway4:on 20.04 and older - Validation – it warns when the gateway is outside the subnet or DNS is missing
- Safe apply steps – backup,
chmod 600andnetplan trywith automatic rollback
Prefer the terminal? See the interactive bash script that does the same on the server itself.

