← Knowledge Base
Ubuntu ServerReference note1 min read · updated 2026-11-27

Ubuntu network configuration with Netplan

Static IP, DHCP and DNS settings in /etc/netplan, and how to apply them without locking yourself out.

netplannetworkubuntu

Ubuntu Server describes the network in YAML files under /etc/netplan/.

# /etc/netplan/01-static.yaml  (example values)
network:
  version: 2
  ethernets:
    enp3s0:
      dhcp4: false
      addresses: [192.168.1.50/24]
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses: [1.1.1.1, 9.9.9.9]
sudo netplan try        # applies, then reverts automatically unless you confirm (safe over SSH)
sudo netplan apply      # apply permanently
ip -br a; ip route

YAML is indentation-sensitive (spaces, not tabs). Use netplan try on remote machines. On cloud images the file is often generated by cloud-init; changes there may be overwritten unless cloud-init's network config is disabled.