Setting up a server often involves getting the network identity right. You might find yourself in a scenario where you have manually set a temporary IP using a legacy command, only to realize the configuration vanished after a simple reboot. Or perhaps you are managing a fleet of cloud instances and need a consistent way to apply DNS settings or bridge interfaces without learning the specific quirks of different background daemons.
These common frustrations are exactly why Netplan was introduced. As the default network configuration utility for modern Ubuntu releases, it provides a centralized, human-readable way to manage your connection state persistently. Whether you are running a simple home lab or a massive data center, mastering Netplan is essential for maintaining a stable and predictable Ubuntu network configuration.
Table of Contents
Key Takeaways: Mastering Netplan
- YAML Syntax → Netplan uses a structured, human-readable format to define network intent.
- Backend Abstraction → It serves as a high-level tool that generates configuration for either NetworkManager or systemd-networkd.
- Persistence → Unlike temporary runtime commands, Netplan ensures your IP addresses and routes survive a system restart.
- Validation → The utility includes a generate command to catch syntax errors before they break your connectivity.
What Problem Does Netplan Solve?
Netplan solves the problem of fragmentation in Linux networking. Before its adoption, administrators had to deal with varying syntax across different tools like ifupdown, NetworkManager, or the iproute2 suite. This made automation difficult because the “language” of network configuration changed depending on whether you were on a desktop or a server.
Netplan provides a distribution-agnostic abstraction layer. You write one unified configuration in a YAML file, and Netplan “renders” those instructions into the correct format for the underlying system backend. This makes it significantly easier to change your IP address in Ubuntu using a standardized workflow regardless of the specific environment.
Common Usage 1: Getting a Network Overview
The first step in any troubleshooting session is seeing what is currently active. While the standard ip addr command shows low-level details, Netplan provides a higher-level summary of your interfaces and correlated information like default routes and DNS servers.
Command: sudo netplan status -a
Expected Output:
Online state: online
DNS Addresses: 127.0.0.53 (stub)
2: enp0s25 ethernet UP (networkd: enp0s25)
Addresses: 10.102.66.200/24 (dynamic, dhcp)
This output confirms the interface is managed by the networkd backend and has successfully received a dynamic address.
Common Usage 2: Configuring Static vs. DHCP Addresses
One of the most frequent tasks is telling the system how to obtain an IP. Netplan allows you to define this clearly within the configuration files located in /etc/netplan/.
- For DHCP: Simply set
dhcp4: trueunder your interface name. - For Static IPs: You must define an
addressesblock and aroutessection for the gateway.
Configuration Example (Static IP):
See also: Mastering the Linux Command Line — Your Complete Free Training Guide
network:
version: 2
renderer: networkd
ethernets:
enp0s25:
addresses:
- 192.168.0.100/24
routes:
- to: default
via: 192.168.0.1
Note: Releases prior to Ubuntu 24.04 (Noble) might use the older gateway4 key instead of the routes block.
Common Usage 3: Overriding DNS and Search Domains
Often, the DNS settings provided by a DHCP server are not sufficient for enterprise needs. Netplan allows you to add a nameservers block to override these defaults or add secondary records.
Configuration Detail: You can specify multiple nameserver addresses and search domains to ensure your system resolves internal resources correctly. This is vital when you need to how to find your IP address in Ubuntu and verify that name resolution is pointing to the correct local mirrors.
Step-by-Step Process: Applying a New Configuration
If you need to update your network settings, follow this verified workflow to avoid losing access to your system:
- Navigate to the config directory: Settings are typically stored in
/etc/netplan/*.yaml. - Backup your current file: Always keep a copy of a working configuration before making changes.
- Edit the YAML file: Use a text editor like
vito modify your IP addresses or routes. - Test for syntax errors: Run
sudo netplan generateto ensure the YAML indentation is correct. - Apply the changes: Execute
sudo netplan applyto make the new settings effective. - Verify the new state: Use
resolvectl statusto confirm the DNS resolver was updated correctly.
Summary Tables
| Netplan Keyword | Primary Purpose | Example Value |
|---|---|---|
| renderer | Defines the backend daemon. | networkd or NetworkManager |
| dhcp4 | Enables/disables IPv4 DHCP. | true or false |
| addresses | Sets fixed IP addresses. | [192.168.1.10/24] |
| via | Defines the default gateway. | 10.10.10.1 |
| nameservers | Configures DNS resolution. | addresses: [8.8.8.8] |
| Command | Action | Recommended Use |
|---|---|---|
netplan generate | Validates YAML syntax. | Before applying any change. |
netplan apply | Pushes config to backends. | To make changes permanent. |
netplan status -a | Shows interface overview. | To troubleshoot connectivity. |
FAQ
Where are the Netplan configuration files located? They are found in /etc/netplan/. Common names include 01-netcfg.yaml or 99_config.yaml.
Why did I lose connection after running ‘netplan apply’? This usually happens due to a syntax error or an incorrect IP assignment. Be extremely careful when changing network parameters over an SSH connection, as you might lose remote access.
Which backend renderer should I choose? By default, systemd-networkd is recommended for servers, while NetworkManager is typically used for desktop environments.


