Skip to content
Linux

Netplan YAML Generator

Generate a correct Netplan file for a static IP or DHCP on Ubuntu 18.04 to 26.04 – with the right gateway syntax, file permissions and apply commands.

Find it with: ip -br link
Runs in your browser – nothing is sent or stored.

Ubuntu configures networking with Netplan YAML files, and a single wrong indent – or the deprecated gateway4 key on newer releases – can leave a server unreachable. Fill in the interface, address, gateway and DNS, pick your Ubuntu release, and get a valid file for 18.04 through 26.04 together with the exact commands to apply it safely.

How to use it

  1. Find the interface name on the server with ip -br link (for example ens18 or enp0s3).
  2. Choose static or DHCP, then fill in the address with its prefix (192.168.1.50/24), gateway and DNS servers.
  3. Copy or download the YAML, then follow the four steps under it: back up, set permissions, netplan try, netplan apply.

What changed between Ubuntu releases

  • 18.04 / 20.04 – gateway4: is the normal way to set the default route.
  • 22.04 and later – gateway4/gateway6 are deprecated; use a routes: list with to: default.
  • 24.04 and later – netplan warns when the file can be read by other users; chmod 600 fixes it.

Working remotely?

Always use sudo netplan try over SSH. If the new settings cut you off, it rolls back by itself after 120 seconds – netplan apply doesn’t.

Frequently asked questions

Why does netplan say gateway4 is deprecated?

From Ubuntu 22.04 the gateway4/gateway6 keys are deprecated in favour of a routes: list with “to: default”. The generator writes the modern form for 22.04 and later.

Why do I get “Permissions for /etc/netplan/… are too open”?

Netplan files can hold Wi-Fi passwords, so newer releases warn unless the file is readable by root only. Run sudo chmod 600 on the file.

How do I apply it without locking myself out?

Use sudo netplan try. It applies the change and rolls back automatically after 120 seconds unless you press Enter to confirm.