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.
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
- Find the interface name on the server with
ip -br link(for exampleens18orenp0s3). - Choose static or DHCP, then fill in the address with its prefix (
192.168.1.50/24), gateway and DNS servers. - 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/gateway6are deprecated; use aroutes:list withto: default. - 24.04 and later – netplan warns when the file can be read by other users;
chmod 600fixes 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.
常见问题
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.
更多工具
全部工具 →Nginx Server Block Generator
Production-ready Nginx server blocks for WordPress/PHP-FPM, static sites and reverse proxies – HTTPS, HTTP/2, www redirect and security headers included.
打开工具 Linuxsystemd Service Generator
Turn any script or app into a systemd service that starts on boot, restarts on failure and runs as a locked-down user.
打开工具 LinuxCrontab Generator
Build a cron schedule from plain choices, read any cron expression in plain English and preview the next run times.
打开工具