
September 11, 2026
10 min read
By Kokil Thapa | Last reviewed: September 2026
Broken SSH after a network edit is one of the fastest ways to lock yourself out of a production VPS. This Ubuntu Netplan Tutorial walks you through Netplan—the default network configuration layer on modern Ubuntu—so you can set static IPs, DHCP, bonds, and bridges without guessing. If you run Ubuntu server setup for Laravel, WordPress, or API workloads, Netplan is the file you touch before Nginx, PHP-FPM, or MySQL ever see traffic. The examples below match what I use on Ubuntu 22.04 and 24.04 LTS servers in Nepal and abroad.
/etc/netplan/, generates backend configs for systemd-networkd or NetworkManager, and applies them with sudo netplan apply. Edit one file, validate syntax, test with netplan try, then apply.What Is Netplan and How Does It Work on Ubuntu?
Netplan is not a network daemon. It is a configuration abstraction that sits between you and the real backend. On Ubuntu Server, that backend is usually systemd-networkd. Desktop installs often use NetworkManager instead. You write human-readable YAML once. Netplan translates it into files the backend understands.
That separation matters in practice. Before Netplan, you edited /etc/network/interfaces on Debian-style systems or chased NetworkManager profiles on desktops. Ubuntu 18.04 and later standardised on Netplan for consistency across cloud images, bare metal, and VMs.
Where Netplan files live
Configuration files belong in /etc/netplan/. Typical names include 00-installer-config.yaml, 50-cloud-init.yaml, or 01-netcfg.yaml. Only .yaml extensions are read. Lexicographic order decides merge priority—later files override earlier ones for the same key.
Check your renderer before editing:
ls -la /etc/netplan/
networkctl status
systemctl is-active NetworkManager Cloud images from AWS, DigitalOcean, Hetzner, and local Nepali hosts often ship a cloud-init file. Read it before you overwrite addresses your provider expects. For broader context, see the Ubuntu network configuration guide.
How Do You Write a Basic Netplan YAML File?
Netplan YAML has three top-level keys you will use daily: network, version, and renderer. Indentation is two spaces. Tabs break parsing. Always back up before editing.
sudo cp /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bak A minimal DHCP example for a single interface:
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: true
dhcp6: false Replace enp0s3 with your interface name from ip link. Names like ens3, eth0, and enp1s0 are common on VPS and bare-metal boxes I maintain for Linux system administration clients.
Validate before apply
Never run netplan apply on a remote server without a safety net. Use this sequence:
sudo netplan --debug generate— catches YAML syntax and schema errors.sudo netplan try— applies temporarily and waits 120 seconds for confirmation.- Press Enter to keep changes, or wait for automatic rollback.
sudo netplan apply— final apply once you are confident.
The official Netplan reference is published at netplan.io/reference. Ubuntu documents server networking at documentation.ubuntu.com/server.
How Do You Configure a Static IP Address with Netplan?
Static IPs are standard on production web servers. Database hosts, mail relays, and firewall rules all expect a fixed address. The pattern below works on a typical /24 LAN or VPS with a known gateway.
network:
version: 2
renderer: networkd
ethernets:
ens3:
dhcp4: false
addresses:
- 192.168.1.50/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses:
- 1.1.1.1
- 8.8.8.8
search:
- lan.local Ubuntu 22.04 and later prefer routes with to: default instead of the deprecated gateway4 key. Older snippets online still show gateway4. It may work but triggers warnings on current releases.
For a focused walkthrough, read configure a static IP on Ubuntu with Netplan. Pair DNS entries with the Ubuntu DNS configuration guide when debugging resolver issues.
Multiple addresses and secondary NICs
Add extra entries under addresses for secondary IPs. Define each physical NIC under ethernets with its own block. Bonding and VLANs use separate top-level keys covered below.
When Should You Use DHCP vs a Static IP in Netplan?
DHCP suits laptops, temporary staging VMs, and home lab machines. Static IPs suit production servers, database hosts, and anything referenced by firewall rules or A records. The wrong choice causes midnight pages.
| Scenario | Recommended mode | Why |
|---|---|---|
| Cloud VPS with provider firewall | Often DHCP or provider-assigned static via cloud-init | Provider metadata may overwrite manual edits on reboot |
| Self-managed dedicated server | Static IP in Netplan | Predictable SSH, mail, and monitoring targets |
| Local LAN dev box | DHCP with reservation on router | Less YAML churn; still predictable MAC binding |
| Docker or KVM host | Static on primary NIC; bridges for guests | Host must stay reachable while guests get own subnets |
| Legal-tech or eCommerce production | Static plus documented DNS | SSL, webhooks, and payment callbacks need stable endpoints |
On sister sites I deploy with Deployer 7—such as legal portals in the Notary Kathmandu portfolio entry—a bad Netplan edit during migration can cut CI/CD deploys instantly. Always schedule network changes outside peak hours for Nepal business traffic.
How Do You Set Up Bonds, Bridges, and VLANs in Netplan?
Advanced layouts appear on KVM hosts, Proxmox nodes, and servers running multiple containers. Bonds aggregate NICs for redundancy. Bridges connect VMs to the physical LAN. VLANs segment traffic without extra hardware.
Network bond example
network:
version: 2
renderer: networkd
ethernets:
enp2s0:
dhcp4: false
enp3s0:
dhcp4: false
bonds:
bond0:
interfaces: [enp2s0, enp3s0]
parameters:
mode: active-backup
primary: enp2s0
mii-monitor-interval: 100
addresses:
- 10.0.0.10/24
routes:
- to: default
via: 10.0.0.1
nameservers:
addresses: [1.1.1.1] Bridge for KVM or LXD
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
dhcp4: false
bridges:
br0:
interfaces: [enp1s0]
dhcp4: false
addresses:
- 192.168.10.5/24
routes:
- to: default
via: 192.168.10.1
parameters:
stp: false
forward-delay: 0 VLAN subinterface
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
dhcp4: false
vlans:
enp1s0.100:
id: 100
link: enp1s0
addresses:
- 10.10.100.2/24 Validate YAML structure with the JSON formatter tool only as a mental check—Netplan is YAML, not JSON—but the same indentation discipline applies. Complex hosts benefit from domain registration and hosting planning so IP, DNS, and SSL line up before go-live.
How Do You Troubleshoot Netplan When the Network Breaks?
I've locked myself out twice in fifteen years of server work. Both times involved a wrong gateway on a remote SSH session. Recovery always started at the provider console—not wishful thinking.
Common failure patterns and fixes:
- YAML indentation error —
netplan generateprints the line number. Fix spaces versus tabs. - Wrong interface name — Run
ip linkfrom console. Predictable names neednet.ifnames=0at boot for legacyeth0style. - Gateway on wrong subnet — Address and gateway must share a routable prefix.
- Cloud-init overwrite — Disable or edit
/etc/cloud/cloud.cfg.d/network snippets if changes vanish on reboot. - NetworkManager conflict — Do not mix manual
nmcliedits with Netplan on the same interface. - DNS works but HTTP fails — Check UFW firewall rules after the IP change.
Diagnostic commands
sudo netplan --debug apply
networkctl status ens3
journalctl -u systemd-networkd -b
resolvectl status
ip -br addr
ip route show After networking is stable, continue the stack build with Nginx on Ubuntu, PHP on Ubuntu, and MySQL on Ubuntu. For Laravel or Symfony deploys, see Symfony deployment on Ubuntu VPS and Docker on Ubuntu.
Cloud-init and persistent changes
On AWS, GCP, Azure, and many budget VPS panels, cloud-init regenerates Netplan at boot. To make manual static configs stick, either disable network management in cloud-init or edit the cloud-init template directly. The systemd-networkd docs at freedesktop.org systemd.network explain the generated file format if you need to debug at that layer.
What Netplan Mistakes Break Production Servers Most Often?
These errors recur across client servers I touch for support and maintenance:
- Applying on SSH without
netplan tryand no console access. - Using
gateway4on Ubuntu 24.04 instead of modernroutessyntax. - Setting
renderer: NetworkManagerwhile editing a server that actually runs networkd. - Forgetting to disable duplicate configs—two files defining the same interface fight at apply time.
- Changing IP without updating DNS A records, mail SPF paths, or payment webhook allowlists.
- Skipping firewall updates after a subnet move—see server hardening for Ubuntu web servers.
On booking platforms like Adventure Third Pole Trek, uptime during trekking season matters. Document every Netplan change in your runbook alongside Ubuntu server backup strategies.
File permissions matter too. Netplan files should be root-owned and not world-writable. Align with Ubuntu file permissions explained and broader Ubuntu security hardening practices.
Key Takeaways
- Netplan YAML lives in
/etc/netplan/; always back up before editing and confirm your renderer withnetworkctl status. - Use
netplan generate, thennetplan try, thennetplan apply—never apply blind over SSH without console access. - Prefer
routes: [{to: default, via: GATEWAY}]over deprecatedgateway4on Ubuntu 22.04 and 24.04. - Match mode to role: DHCP for transient hosts, static IPs for production web and database servers.
- On cloud VPS instances, check cloud-init so your Netplan changes survive reboot.
- After IP changes, update DNS, firewall rules, and monitoring before closing the maintenance window.
People Also Ask
Does Ubuntu Desktop use Netplan the same way as Ubuntu Server?
Both use Netplan, but desktops often set renderer: NetworkManager while servers default to systemd-networkd. GUI network settings may overwrite YAML on desktop installs. On servers, you typically manage everything through Netplan files and CLI tools.
Where does Netplan write its generated configuration?
For systemd-networkd, generated units appear under /run/systemd/network/ at runtime. NetworkManager gets keyfile snippets under /run/NetworkManager/. You rarely edit these directly—fix the YAML source and regenerate.
Can you use Netplan with Wi-Fi interfaces?
Yes. Define the wireless device under wifis: with access-point name and credentials. Server tutorials focus on Ethernet, but the same apply workflow applies. NetworkManager renderer is common for Wi-Fi on laptops.
What happens if two Netplan files conflict?
Files merge in lexicographic order. Later filenames override earlier keys for the same interface. Keep one authoritative file when possible, or prefix with 01-, 50-, 99- intentionally so priority is obvious.
Put Netplan to Work on Your Next Server
You now have a complete Ubuntu Netplan Tutorial path—from DHCP basics to bonds, bridges, VLANs, and recovery when something goes wrong. Netplan is boring infrastructure until it isn't; the five minutes you spend on netplan try can save hours at a provider console. If you want hands-on help wiring Ubuntu servers for Laravel, WordPress, or client portals, review available services or contact us for deployment support. For day-one server tasks after networking, start with essential Ubuntu terminal commands and the Ubuntu server monitoring guide.
Frequently Asked Questions
0 Comments
Leave a comment
Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

