This tutorial provides a concise guide to configuring a static IP with Netplan on Ubuntu 26.04 Server. If you need comprehensive coverage including desktop GUI methods, multiple IP addresses, or advanced scenarios, see our complete static IP configuration guide.
Software Requirements and Linux Command Line Conventions
Category
Requirements, Conventions or Software Version Used
System
Ubuntu 26.04 Resolute Raccoon
Software
Netplan (installed by default)
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
Configure a static IP netplan Ubuntu 26.04 Server by editing the YAML file in /etc/netplan/, setting dhcp4: false, and defining your IP address, gateway, and DNS servers.
Quick Steps to Configure Static IP with Netplan
Step
Command/Action
1. Find config file
ls /etc/netplan/
2. Edit netplan config
sudoedit /etc/netplan/00-installer-config.yaml
3. Apply configuration
sudo netplan apply
Configure Static IP with Netplan on Ubuntu 26.04 Server
Ubuntu Server uses Netplan for network configuration with YAML syntax. The following steps show how to configure a static IP on a typical Ubuntu 26.04 Server installation.
Identify your network interface: Use the ip a command to find your network interface name:
$ ip a
Look for the interface with an active connection (state UP). Common names include ens18, enp0s3, or eth0. Note this name for the next steps.
Locate the Netplan configuration file: List files in the Netplan directory:
$ ls /etc/netplan/
On a standard Ubuntu Server installation, you will find 00-installer-config.yaml created by the subiquity installer. Other possible filenames include 01-netcfg.yaml or 50-cloud-init.yaml.
View current configuration: Check the existing settings before making changes:
$ cat /etc/netplan/00-installer-config.yaml
A default DHCP configuration looks like this:
# This is the network config written by 'subiquity'
network:
ethernets:
ens18:
dhcp4: true
dhcp6: true
match:
macaddress: bc:24:11:5e:a0:5f
set-name: ens18
version: 2
Edit the configuration: Open the file for editing:
$ sudoedit /etc/netplan/00-installer-config.yaml
Replace the DHCP configuration with a static IP configuration. The following example sets the IP address to 172.16.1.170 with gateway 172.16.1.1:
YAML INDENTATION
Netplan uses strict YAML formatting. Use spaces (not tabs) and maintain consistent indentation. Incorrect indentation will cause errors when applying the configuration.
If your Ubuntu Server was deployed in a cloud environment or uses cloud-init, your Netplan configuration file may be 50-cloud-init.yaml with a header stating changes will not persist. In this case, you must disable cloud-init network management before configuring a static IP.
Check for the cloud-init header:
$ head -2 /etc/netplan/50-cloud-init.yaml
If present, disable cloud-init network configuration:
After disabling cloud-init, you can safely edit the Netplan configuration following the steps above. For more details on Netplan configuration options, see our comprehensive Netplan guide.
Conclusion
You have successfully configured a static IP netplan Ubuntu 26.04 Server. The configuration persists across reboots, providing a fixed IP address for your server. To revert to DHCP, simply change dhcp4: false back to dhcp4: true and remove the addresses, routes, and nameservers sections, then run sudo netplan apply.
Frequently Asked Questions
Why is my static IP configuration not persisting after reboot? Your system likely uses cloud-init to manage network configuration. Check if your netplan file contains a cloud-init header comment and disable cloud-init network management as described in the Cloud-Init Considerations section above.
What happened to the gateway4 option in Netplan? The gateway4 option has been deprecated. Use the routes configuration with to: default and via: your-gateway-ip instead, as shown in the examples above.
How do I set a static IP without losing SSH connectivity? When configuring a static IP remotely via SSH, ensure your new IP address is on the same subnet as your current connection. Apply the configuration with sudo netplan apply and immediately reconnect using the new IP address if it differs from the DHCP-assigned one.