Netplan and the current config
How Ubuntu configures the network, where the files are, and how to see the current IP, gateway and interfaces.
How it works
Ubuntu Server describes the network in Netplan YAML files in /etc/netplan/. Netplan itself doesn’t run anything. It translates your YAML into config for the real network service (the renderer):
flowchart LR
Y["/etc/netplan/*.yaml"] -->|netplan apply| N["systemd-networkd
(server)"]
Y -.->|or| NM["NetworkManager
(desktop)"]
N --> I["interfaces
IP, routes, DNS"]
So: change the YAML, then netplan apply. Don’t edit /etc/network/interfaces, that is the old system and is ignored.
See the current config
| What | Command |
|---|---|
| Interfaces, IPs, routes, DNS in one view | sudo netplan status (24.04+) |
| IP addresses (short) | ip -br a |
| IP addresses (full) | ip a |
| Default gateway and routes | ip r |
| Link state (up/down) and MAC | ip -br link |
| DNS servers in use | resolvectl status |
| What Netplan will apply | sudo netplan get |
| The files themselves | ls /etc/netplan/ and sudo cat /etc/netplan/*.yaml |
ip replaces the old ifconfig and route, which are not installed by default.
The files
Files are read in alphabetical order; later files override earlier ones.
| Typical file | Created by |
|---|---|
50-cloud-init.yaml | cloud-init: cloud images, VM templates, and the 24.04 installer |
00-installer-config.yaml | The Ubuntu Server 22.04 installer |
A minimal file with DHCP looks like this:
network:
version: 2
ethernets:
ens18:
dhcp4: true
Interface names like ens18, eth0 or enp3s0 come from ip -br link.
cloud-init overwrites my changes
If your file says it was generated by cloud-init, your edits may be replaced on the next boot. Tell cloud-init to leave the network alone:
echo "network: {config: disabled}" | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
Then edit the Netplan file (or create your own, e.g. 60-static.yaml).
Netplan commands
| Command | Does |
|---|---|
sudo netplan generate | Check the YAML and generate backend config, without applying |
sudo netplan try | Apply, and roll back after 120 s unless you press Enter. Use this over SSH! |
sudo netplan apply | Apply for real |
sudo netplan get | Show the merged config |
sudo netplan set ethernets.ens18.dhcp4=false | Change one value from the command line |