Linux Linux NetworkingNetplanStatic IPUbuntu Server

Article & Tutorial

Configure a Static IP on Ubuntu with Netplan

Configure a static IPv4 address on Ubuntu with Netplan, including interface discovery, YAML structure, default routes, DNS, safe testing, permissions, and troubleshooting.

Ubuntu server network configuration with a static IP address
Ubuntu server network configuration with a static IP address
Contents

Ubuntu Server commonly uses Netplan to describe network configuration in YAML. Before changing a remote machine, keep console access available: a typo in an interface name, address, route, or indentation can disconnect the server.

Collect the current network details

  • Identify the interface name with ip link or ip address.
  • Record the current address, prefix length, gateway, and DNS servers.
  • Check which renderer is in use, typically systemd-networkd on servers or NetworkManager on desktops.
  • Confirm that the planned static address is outside the DHCP pool or reserved for this host.

Define the Netplan configuration

Edit a YAML file in /etc/netplan. Under network, set version 2, define the correct interface under ethernets, disable DHCP for the address family you are configuring, add the address with its CIDR prefix, define the default route, and list DNS servers. Use spaces only; YAML indentation is significant.

SettingExample valuePurpose
addresses192.168.10.25/24Static address and prefix
default route0.0.0.0/0 via 192.168.10.1Default IPv4 gateway
nameservers192.168.10.10, 1.1.1.1DNS resolvers
dhcp4falsePrevents IPv4 DHCP assignment

Test safely before committing

Restrict the configuration file to root where appropriate, generate the backend configuration, and use netplan try for a remote system. The temporary test requires confirmation and can roll back automatically if connectivity is lost. After confirmation, apply the configuration and inspect the resulting address and routes.

Validate the result

  1. Confirm the expected address on the intended interface.
  2. Inspect the routing table and verify the default route.
  3. Test the local gateway before testing an external address.
  4. Test DNS resolution separately from raw IP connectivity.
  5. Reboot during a maintenance window to confirm persistence.

Common problems

  • Wrong interface name after hardware or virtual NIC changes.
  • Tabs or inconsistent indentation in YAML.
  • Multiple Netplan files defining the same interface.
  • A duplicate IP address already used by another device.
  • An unreachable gateway or incorrect prefix length.
  • Cloud-init regenerating network settings on cloud images.

Server naming and local resolution

A local hosts entry can map the server address to its fully qualified and short hostname, but it does not replace authoritative DNS. Keep forward and reverse DNS aligned for infrastructure that depends on consistent name resolution.

Netplan configuration examples

Did this help?

Yes No

Join the discussion

0 Comments

Ask questions, add context, or share what worked.

Sign in to join the discussion

No comments yet. Start the discussion.

More from Melochip Editorial

Related articles

Stay in the loop. Get new Melochip articles

Receive Melochip article updates when new articles are available. Explicit opt-in only.

No pre-checked boxes. Unsubscribe support is part of the subscriber foundation.