Tools: Configure static IP address on Netplan (2026)

Tools: Configure static IP address on Netplan (2026)

Finding your network interface

Configuring Netplan

Applying the changes

Verifying the changes I've recently set up a new Ubuntu Server 24.04 and needed to assign it a static IP address. For a server, you don't want the IP to change whenever DHCP leases expire. Before making any configuration changes, you need to know the name of your network interface. On Ubuntu Server, you'll likely see something like ens33 or enp0s3. Run this command to see all network interfaces: Look for the interface that has an IP address assigned to it. That's the one you want to configure. In my case, it was enp0s3. Ubuntu Server 24.04 stores network configuration in /etc/netplan/. There's usually a file there called something like 50-cloud-init.yaml. Let's check what's in that directory: Open the configuration file and you will see something like this by default: Change it to use a static IP instead. Here's what I configured: As you can see, the IP address includes the CIDR notation. The CIDR /24 means a subnet mask of 255.255.255.0. I'm using explicit routes instead of the older gateway4 key, because Ubuntu 24.04 deprecated gateway4. For DNS, I pointed to Cloudflare's public DNS servers, but you can use the DNS servers of your choice. Once the file is saved, instruct Netplan to apply the changes: Check that your static IP is now assigned: It should now show your new static IP address. Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to ? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Code Block

Copy

ip link /etc/netplan/ 50-cloud-init.yaml ls /etc/netplan/ ls /etc/netplan/ ls /etc/netplan/ vi /etc/netplan/50-cloud-init.yaml vi /etc/netplan/50-cloud-init.yaml vi /etc/netplan/50-cloud-init.yaml network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: true network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: true network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: true network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: false dhcp6: false addresses: - 192.168.1.100/24 routes: - to: default via: 192.168.1.1 nameservers: addresses: - 1.1.1.1 - 1.0.0.1 network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: false dhcp6: false addresses: - 192.168.1.100/24 routes: - to: default via: 192.168.1.1 nameservers: addresses: - 1.1.1.1 - 1.0.0.1 network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: false dhcp6: false addresses: - 192.168.1.100/24 routes: - to: default via: 192.168.1.1 nameservers: addresses: - 1.1.1.1 - 1.0.0.1 255.255.255.0 sudo netplan apply sudo netplan apply sudo netplan apply ip addr show enp0s3 ip addr show enp0s3 ip addr show enp0s3