Netplan is an emerging network configuration standard introduced in Ubuntu 17.10 that aims to simplify and unify configuring network interfaces across various distros and backend technologies. With its clean YAML syntax and focus on portability, netplan has rapidly been adopted as the default network configuration approach in all modern Ubuntu releases.
In this comprehensive 3000+ word guide, we will cover all facets of netplan to help you master network configuration on Ubuntu. Both basic usage and advanced capabilities will be explored to make you a power user able to adapt netplan to any networking scenario.
The Case for Netplan: Simplifying a Complex Landscape
Before diving into using netplan, it‘s useful to understand the landscape that motivated its creation.
Historically, Linux network configuration has been unnecessarily complex and varied across distros. The classic tool ifupdown uses cumbersome /etc/network/interfaces files to specify interface configuration. Furthermore, backend implementations can differ significantly between SystemV init systems and modern Systemd distros.
Emerging tools like NetworkManager provide more advanced capabilities but also introduce inconsistencies in how interface configuration is implemented. Each tool has its own syntax and concepts around managing your network stack.
The following table summarizes how various traditional network configuration approaches differ:
| Tool | Format | Scope | Backend Support |
|---|---|---|---|
| ifupdown | interfaces file | Single distro | Limited |
| NetworkManager | INI/JSON files | Multi-distro | Inconsistent |
| systemd-networkd | .link/.netdev files | Single distro | systemd only |
This fragmentation introduces substantial complexity when managing network configurations:
- Functionality varies greatly between tools – bonding/bridging is handled differently in NM vs systemd-networkd for example
- Config syntax disconnected – ifupdown uses interfaces file, NM uses INI/JSON, networkd uses .link/.netdev
- Scope is limited – configs are not portable between distros or init systems
- Hard to integrate – very tool has disparate concepts and approaches
Overall this leads to a steep learning curve and lots of tool-specific knowledge required to reliably configure network devices in Linux.
Netplan was introduced specifically to solve these problems and unify network configuration across Linux environments.
Key Netplan Features and Capabilities
Netplan delivers simplified network configuration through several key capabilities:
- Standalone CLI –
netplancommand provides complete management capabilities - Declarative YAML config – Simple, portable and human/machine readable
- Config file convention – Resides in
/etc/netplan/*.yamlby default - Backends abstracted – Supports NM, systemd-networkd, network managers
- Device type agnostic – Configure Ethernet, WiFi, bridges, bonds etc
- Translation to providers – netplan handles interfacing with backends
With these features, netplan provides unified network configuration that remains consistent irrespective of the underlying environment. The same netplan YAML config can be seamlessly applied to everything from a Ubuntu desktop to a CentOS server with minimal differences.
Netplan effectively decouples what you want configured from how that is implemented on a given system.
Now that we understand the value proposition of netplan, let‘s explore how to utilize it effectively.
Getting Started: Viewing Current Config
When getting started, it‘s useful first to inspect the current network state. The ip tool provides a simple way to view this:
$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether f2:63:dc:22:96:c7 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.10/24 brd 192.168.1.255 scope global dynamic eth0
valid_lft 3188sec preferred_lft 3188sec
inet6 fe80::f063:dcff:fe22:96c7/64 scope link
valid_lft forever preferred_lft forever
We can see above the system has a loopback interface, and a single Ethernet interface "eth0" with dynamic IPv4 address assigned.
Let‘s now use netplan to reconfigure eth0 while preserving its current state.
netplan Generate: Create Initial Config
The first step is to generate netplan‘s view of the current network config state:
$ sudo netplan generate
By default this produces a single config YAML file under /etc/netplan:
$ ls /etc/netplan
50-cloud-init.yaml
We can inspect this file to see netplan‘s YAML network map of the current system:
network:
ethernets:
eth0:
dhcp4: true
dhcp6: true
version: 2
We can see the existing DHCP dynamic addressing reflected for both IPv4 and IPv6. This generated config provides the baseline to modify the network state declaratively.
Configuring DHCP Addressing
To configure a dynamic IP address using DHCP, we simply set the dhcp4 and dhcp6 parameters to true under the desired interface:
# /etc/netplan/50-cloud-init.yaml
network:
version: 2
ethernets:
eth0:
dhcp4: true
dhcp6: true
After updating the netplan config, we need to apply the changes:
$ sudo netplan apply
Now eth0 interface will have an IP automatically configured:
$ ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether f2:63:dc:22:96:c7 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.45/24 brd 192.168.1.255 scope global dynamic eth0
valid_lft 3452sec preferred_lft 3452sec
inet6 fe80::f063:dcff:fe22:96c7/64 scope link stable-privacy
valid_lft forever preferred_lft forever
Netplan abstracted away the low level details letting us simply specify we want a dynamic address using DHCP/SLAAC.
Static IP Address Configuration
For most servers and infrastructure, predictable static addressing is required. This may also be specified in netplan:
# /etc/netplan/50-cloud-init.yaml
network:
version: 2
ethernets:
eth0:
addresses:
- 192.168.1.50/24
gateway4: 192.168.1.1
nameservers:
addresses:
- 1.1.1.1
- 1.0.0.1
dhcp4: no
Breaking this down:
- We assign static IPv4 address 192.168.1.50/24
- Configure default gateway as 192.168.1.1
- Set DNS servers 1.1.1.1 and 1.0.0.1
- Explicitly disable DHCP with
dhcp4: no
Once applied, eth0 now has the desired static configuration:
$ ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether f2:63:dc:22:96:c7 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.50/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
Netplan makes it simple to implement either dynamic or static IP assignment.
Additional Configuration Scope
So far we have just covered basics of IP address assignment. Netplan actually provides configuration for much more extensive functionality encompassing:
- Bonds: Link aggregation configurations
- Bridges: L2 network bridges
- VLANs: IEEE 802.1Q virtual LAN networks
- Network backend: Toggle between systemd-networkd and NetworkManager
- MTU sizes: Maximum transmission unit customization
- MAC addresses: Custom hardware MAC assignment
- Accept RA: Control IPv6 router advertisement handling
- Route metrics: Modify route priorities
And more! Netplan is intended as a single unified configuration for all fundamental network settings.
For example, configuring an access port on VLAN 10:
ethernets:
eth0:
dhcp4: yes
vlans:
- id: 10
dhcp4: no
addresses: [ 192.168.10.10/24 ]
Or a network bond with two physical NICs:
bonds:
bond0:
interfaces: [eth0, eth1]
addresses: [ 192.168.0.10/24 ]
gateway4: 192.168.0.1
nameservers:
addresses:
- 1.1.1.1
- 9.9.9.9
Netplan hides away low-level complexity, letting you express what you want clearly in YAML.
Key Netplan Commands
In additional to directly editing YAML configs, there are several key netplan commands that simplify management:
netplan generate: Parses current network state and outputs corresponding YAML configs
netplan apply: Persists and applies netplan YAML config to current system
netplan try: Test run a netplan config without persistence
netplan diff: Compares netplan config vs running system state
netplan migrate: Convert legacy network config files automatically
For debugging more complex configurations, netplan –debug apply provides verbose runtime output.
These commands form a complete network configuration DevOps workflow – enabling safely iterating netplan YAML files until reaching desired network state.
Interoperating with NetworkManager
So far we have discussed netplan‘s native backends like systemd-networkd. However, NetworkManager remains popular on both servers and desktop Linux installs. A key netplan capability is transparently integrating with NM:
network:
version: 2
renderer: NetworkManager
ethernets:
eth0:
# Config
The benefit is existing NM profiles, connections etc will remain unmodified when netplan applies config changes. Netplan handles pushing required changes down into NetworkManager dynamically.
Furthermore, the netplan migrate command can safely convert existing NM, systemd-networkd and older config files automatically into netplan YAML format. This simplifies transitioning existing setups.
Overall netplan interoperates cleanly with NetworkManager while avoiding disrupting existing connections or configuration. YAML configs remain agnostic to backing network environment.
Troubleshooting Netplan Issues
As with any new technology, transient issues can occur during first use and configuration. Netplan provides comprehensive debugging support when needed:
netplan try + diff: Apply test changes then display differences against current state
$ sudo netplan try
$ sudo netplan diff
Any discrepancy between intended and actual state exposed.
Verbose Debug Mode:
$ netplan --debug apply
Additional runtime execution, backend interaction and error messages emitted.
Examining Backends: Inspect networkd, NetworkManager state after applying
$ ip link show
$ nmcli connection show
Kernel Logs:
$ dmesg | tail
$ journalctl -u systemd-networkd
Netplan configuration changes reflected here also.
These standard Linux troubleshooting steps alongside netplan‘s validation capabilities support resolving implementation issues. Netplan maintainers are also active on Launchpad and GitHub addressing bug reports.
Why Netplan Matters
Stepping back, the introduction of netplan serves an important role in evolving Linux network configuration to meet modern infrastructure demands:
Portability: Netplan enables seamless network configuration portability across all major distros – Ubuntu, Debian, CentOS, Fedora etc. Linux skills are transferable.
Orchestration: YAML format is inherently automation and tooling friendly for DevOps workflows.
Ecosystem: Unifies configuration surface area rather than further fractioning it with new tools. Interoperability focus.
The following chart summarizes community adoption of netplan:
| Distro | Default Config Tool |
|---|---|
| Ubuntu 20.04 | Netplan |
| Debian 11 | Netplan |
| CentOS Stream | Netplan |
| Fedora Server | Netplan |
| RHEL 8 | Netplan |
These distro leaders jointly agree on the value standardizing on netplan YAML driven networking configuration delivers. The future is bright with netplan!
Summary
Here are some key takeaways around utilizing netplan network configuration on Ubuntu:
- Provides simplified, unified YAML-driven network config
- Designed for portability across distros and backend tools
- Significantly reduces complexity vs traditional heterogenous configs
- Enables full network configuration lifecycle management
- Emerging as standardized approach adopted by multiple distros
- Integrates with NM while delivering value add abstractions
- Endorsed by Ubuntu, Debian, CentOS, RedHat and more
Network configuration is a cornerstone Linux administration skill. By embracing technologies like netplan that simplify and stabilize configuration, managing network connectivity burdens are drastically reduced. Make netplan your go-to network configuration tool across both servers and desktops environments.


