Netplan is the default network configuration tool for Ubuntu, providing a unified interface for managing network settings through simple YAML files. This netplan ubuntu 26.04 guide covers the essentials you need to understand and configure networking on Ubuntu Server, from file structure and syntax to applying and validating your configurations.
Table of Contents
In this tutorial you will learn:
- Where Netplan configuration files are located
- How to write valid YAML syntax for network configuration
- Common Netplan configuration examples
- How to safely apply and test configuration changes
- How to validate and troubleshoot Netplan errors

Software Requirements
| Category | Requirements, Conventions or Software Version Used |
|---|---|
| System | Ubuntu 26.04 Resolute Raccoon |
| Software | Netplan.io (pre-installed) |
| Other | Privileged access to your Linux system as root or via the sudo command. |
| Conventions | # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
DESKTOP USERS
Ubuntu Desktop uses NetworkManager as the default renderer, which manages network connections through the GUI. If you edit Netplan files directly on desktop systems, NetworkManager may override your settings. For Ubuntu Desktop, use Settings → Network or the nmcli command instead. This guide focuses on Ubuntu Server, which uses systemd-networkd as the backend renderer.
/etc/netplan/. Edit your configuration file, then apply changes safely with sudo netplan try.
| Step | Command/Action |
|---|---|
| 1. List configuration files | ls /etc/netplan/ |
| 2. Edit configuration | sudo nano /etc/netplan/00-installer-config.yaml |
| 3. Test configuration (with rollback) | sudo netplan try |
| 4. Apply permanently | sudo netplan apply |
Netplan File Structure on Ubuntu 26.04
Netplan reads configuration files from three directories, processed in the following order of priority:
/run/netplan/– Runtime configurations (highest priority, temporary)/etc/netplan/– Administrator configurations (primary location for your changes)/lib/netplan/– System package defaults (lowest priority)
Files within each directory are processed in lexicographical order, meaning 00-installer-config.yaml is read before 99-custom.yaml. Later files can override settings from earlier ones.
Depending on your Ubuntu installation method, you may encounter different default configuration files in /etc/netplan/:
00-installer-config.yaml– Created by Ubuntu Server installer (subiquity)01-netcfg.yaml– Generic configuration filename01-network-manager-all.yaml– Ubuntu Desktop (defers to NetworkManager)50-cloud-init.yaml– Cloud deployments (AWS, Azure, GCP, OpenStack)
To identify your current configuration file, run:
$ ls -la /etc/netplan/

You can create your own configuration file with any name ending in .yaml. Netplan scans all YAML files in the directory regardless of filename. Files are processed alphabetically, so 99-custom.yaml would override settings from 00-installer-config.yaml for the same interface. You can either edit the existing file, create a new one alongside it, or replace it entirely.
When creating a new configuration file, set proper permissions to avoid security warnings:
$ sudo touch /etc/netplan/99-custom.yaml $ sudo chmod 600 /etc/netplan/99-custom.yaml
PERMISSIONS WARNING
If file permissions are too open, Netplan displays: WARNING: Permissions for /etc/netplan/filename.yaml are too open. Netplan configuration should NOT be accessible by others. The configuration still applies, but you should restrict permissions with chmod 600 to prevent other users from reading network credentials such as Wi-Fi passwords.
YAML Syntax Essentials for Netplan
Netplan uses YAML (YAML Ain’t Markup Language) for configuration. Understanding YAML syntax is critical because even minor formatting errors will prevent your network configuration from applying. Consequently, paying attention to indentation and structure saves significant troubleshooting time.
Key YAML rules for Netplan:
Indentation uses spaces, not tabs. Netplan requires exactly 2 spaces per indentation level. Tabs will cause parsing errors.
# Correct - 2 spaces per level
network:
version: 2
ethernets:
ens18:
dhcp4: true
Colons must be followed by a space. When assigning values, always include a space after the colon.
# Correct dhcp4: true # Wrong - missing space dhcp4:true
Lists use hyphens with consistent indentation. Each list item starts with a hyphen and space.
# Correct list format
addresses:
- 172.16.1.170/24
- 172.16.1.171/24
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
Boolean values are lowercase. Use true and false, not True, TRUE, yes, or no.
Netplan Configuration Examples on Ubuntu 26.04
The following examples demonstrate common netplan ubuntu 26.04 configurations. Each example shows a complete, working configuration file that you can adapt to your environment.
INTERFACE NAME
All examples below use ens18 as the network interface name. Your interface name will likely differ. To determine your interface name, run:
$ ip link
Common interface names include ens18, enp0s3, ens33, or eth0 depending on your hardware and virtualization platform. Replace ens18 with your actual interface name in all configurations.
- DHCP Configuration (Default): The simplest configuration obtains network settings automatically from a DHCP server.
network: version: 2 ethernets: ens18: dhcp4: true dhcp6: trueThis configuration enables IPv4 and IPv6 DHCP on the specified interface. This matches the default Ubuntu Server installer configuration.
- Static IP Configuration: For servers requiring a fixed IP address, disable DHCP and specify network parameters manually.
network: version: 2 ethernets: ens18: dhcp4: false addresses: - 172.16.1.170/24 routes: - to: default via: 172.16.1.1 nameservers: addresses: - 8.8.8.8 - 8.8.4.4This assigns IP
172.16.1.170with a/24subnet mask, sets the default gateway to172.16.1.1, and configures Google’s DNS servers. For a detailed walkthrough, see how to configure static IP with Netplan. - Custom DNS Servers: You can configure DNS servers independently of your IP configuration method.
network: version: 2 ethernets: ens18: dhcp4: true nameservers: addresses: - 1.1.1.1 - 9.9.9.9 search: - example.com - internal.localThis uses DHCP for IP addressing but overrides DNS with Cloudflare (
1.1.1.1) and Quad9 (9.9.9.9). Thesearchdirective appends these domains when resolving short hostnames. - Static Route Configuration: Adding a static route directs traffic for specific networks through a designated gateway.
network: version: 2 ethernets: ens18: dhcp4: true routes: - to: 10.10.0.0/16 via: 172.16.1.254This configuration uses DHCP for the default network settings but adds a static route directing all traffic destined for
10.10.0.0/16through gateway172.16.1.254. This is useful for reaching networks behind a secondary router or VPN gateway.
OPTIONAL PARAMETERS
Your default configuration may include additional parameters like match: and set-name: which the Ubuntu installer uses for interface matching. These are optional for basic configurations and can be safely omitted in custom configurations.
Applying Netplan Configuration on Ubuntu 26.04
After modifying your Netplan configuration files, you must apply the changes for them to take effect. Netplan provides three commands for this purpose, each serving a different role in the configuration workflow.
- netplan try (Recommended for Testing): This command applies configuration changes temporarily with an automatic rollback safety net.
$ sudo netplan try
After applying, Netplan waits for confirmation. If you don’t press ENTER within 120 seconds (or if you lose network connectivity), it automatically reverts to the previous working configuration. This is invaluable when configuring remote servers where a misconfiguration could lock you out.
- netplan apply (Permanent Application): Once you’ve verified your configuration works correctly, apply it permanently.
$ sudo netplan apply
This command applies the configuration immediately without a rollback timer. Use this only after testing with
netplan tryor when you have physical/console access to the machine. - netplan generate (Debug Backend Configuration): This command generates backend-specific configuration files without applying them.
$ sudo netplan generate
Netplan translates YAML configurations into files for the underlying renderer (systemd-networkd or NetworkManager). The generated files are placed in
/run/systemd/network/for systemd-networkd. This is useful for debugging or understanding what Netplan creates.

Validating and Troubleshooting Netplan on Ubuntu 26.04
When your netplan ubuntu 26.04 configuration doesn’t work as expected, follow these steps to identify and resolve issues.
- Validate YAML syntax: Before applying, check your configuration file for syntax errors.
$ sudo netplan generate
If there are YAML errors, Netplan outputs specific line numbers and error descriptions. Common errors include incorrect indentation, missing colons, or tabs instead of spaces.
COMMON ERROR
Error in network definition: unknown key 'adresses'– This typically indicates a typo. Check spelling carefully (addresses, not adresses). - View generated configuration: Examine what Netplan creates for the backend renderer.
$ cat /run/systemd/network/10-netplan-ens18.network
This shows the actual systemd-networkd configuration generated from your YAML file. If settings appear incorrect here, the issue is in your Netplan YAML.
- Check network interface status: Verify your interface has the expected configuration applied.
$ ip addr show ens18 $ ip route show
The first command displays IP addresses assigned to the interface. The second shows the routing table, including your default gateway and any static routes.
- Test connectivity: Verify network functionality after applying changes.
$ ping -c 3 172.16.1.1 # Test gateway $ ping -c 3 8.8.8.8 # Test internet $ ping -c 3 example.com # Test DNS resolution
If gateway ping fails, check your IP and gateway configuration. If internet works but DNS fails, verify your nameserver settings.
- Review system logs: For persistent issues, check systemd-networkd logs.
$ journalctl -u systemd-networkd --since "10 minutes ago"
This reveals detailed information about network interface initialization and any errors encountered by the network daemon.
For additional troubleshooting, consult the official Netplan documentation.
Conclusion
This guide covered the essential aspects of netplan ubuntu 26.04 configuration, including file locations, YAML syntax requirements, common configuration examples, and methods for applying and validating changes. Understanding these fundamentals enables you to confidently configure Netplan for static IPs, custom DNS, and routing on Ubuntu Server.
For more specific configurations, refer to our detailed guides on setting static IP with Netplan, configuring DHCP with Netplan, and applying Netplan changes.
Frequently Asked Questions
- What is the difference between netplan try and netplan apply? The
netplan trycommand applies your configuration temporarily and automatically reverts after 120 seconds unless you confirm. This provides a safety net when making changes remotely. Thenetplan applycommand applies changes permanently without any rollback mechanism. - Why does Netplan show “Error in network definition” when my YAML looks correct? YAML is sensitive to indentation. Ensure you use exactly 2 spaces (not tabs) per indentation level. Also verify colons have a space after them and check for typos in key names like
addressesornameservers. - Which Netplan configuration file should I edit? Edit the file in
/etc/netplan/that exists on your system. On Ubuntu Server, this is typically00-installer-config.yaml. You can create additional files with higher numbers (like99-custom.yaml) to override specific settings without modifying the original file. - Can I have multiple IP addresses on a single interface with Netplan? Yes, add multiple entries under the
addresseskey as a YAML list. Each address should include its CIDR notation, for example- 172.16.1.170/24and- 172.16.1.171/24. - How do I find my network interface name for Netplan configuration? Run
ip linkorip addrto list all network interfaces. Modern Ubuntu uses predictable interface names likeens18,enp0s3, oreth0depending on your hardware and virtualization platform.