Configure Netplan Static IP

Updated: 2022.11.23


Debian / Ubuntu

Assign a static IP on your Ubuntu system using Netplan.


  • Ubuntu installation completed.
  • Logged in as administrative user.

Netplan Files

Your Ubuntu system likely already has a Netplan configuration file present in the /etc/netplan/ directory; it may have one of three names: 01-netcfg.yaml, 01-network-manager-all.yaml, or 50-cloud-init.yaml. The leading number (##-) in the filename indicates the order of priority in which Netplan will apply the included rules.


The 01-netcfg.yaml file may be used to manually configure the system’s network interfaces. If this file already exists, it likely contains a DHCP configuration that we will edit in the next section. If your system is using one of the other configuration files listed below, they should be disabled after setting up 01-netcfg.yaml.


The 01-network-manager-all.yaml file will contain a configuration instructing Ubuntu to allow NetworkManager to control all interfaces on the system. Usage of NetworkManager is beyond the scope of this bit, and likely not relevant on a server installation. The configuration will resemble the following. Remove this file after setting up 01-netcfg.yaml if you do not wish to use NetworkManager.

# Let NetworkManager manage all devices on this system
  version: 2
  renderer: NetworkManager


The 50-cloud-init.yaml file will be present if the network interface was configured using cloud-init . The configuration will be prefaced with the following comment. Follow comment’s disable instructions after setting up 01-netcfg.yaml if you do not wish to use cloud-init.

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}

If your server is hosted with a cloud provider, refer to the providers documentation for editing the IP address when a cloud-init.yaml file is present; you may not be able to change the address on the system.

Set IP Address

Create or open the 01-netcfg.yaml file in your editor of choice. Interface eth0 will be used as example in this section, replace it with whatever interface you are configuring.

sudo nano /etc/netplan/01-netcfg.yaml


The following configuration is what you would see for a DHCP configuration on interface eth0.

  version: 2
  renderer: networkd
      dhcp4: yes


The next snippet is an example of a static IP definition for interface eth0. Paste it into 01-netcfg.yaml and modify it to suit your server.

  • Replace eth0 with your interface of choice.
  • Set dhcp4 to no, disabling DHCP.
  • Set addresses to the IP address you want the system to have.
  • Set gateway4 to the router’s IP address.
  • Replace nameservers: addresses with your DNS servers of choice.
  version: 2
  renderer: networkd
      dhcp4: no
      addresses: []
        addresses: [,]


After configuring Netplan, and disabling any Netplan configurations you do not plan on using, apply the changes.

sudo netplan --debug apply