Ubuntu 24.04 LTS uses Netplan to manage network configuration. By default, servers use DHCP which can result in IP address changes. This guide configures a static IP address using Netplan on Ubuntu 24.04 LTS.

Tested and valid on:

  • Ubuntu 24.04 LTS

Prerequisites

  • Ubuntu 24.04 LTS server
  • A user with sudo privileges
  • Knowledge of your network settings (IP, gateway, DNS)

Step 1 – Identify Your Network Interface

List network interfaces:

ip link show
ip addr show

Step 2 – Find the Netplan Configuration File

Netplan configs are in /etc/netplan/:

ls /etc/netplan/

Step 3 – Back Up the Existing Config

Always back up before editing:

sudo cp /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bak

Step 4 – Edit the Netplan Configuration

Open the configuration file:

sudo nano /etc/netplan/00-installer-config.yaml

Replace the content with a static IP configuration (adjust interface name and addresses):

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses:
        - 192.168.1.100/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
          - 1.1.1.1
          - 8.8.8.8
      dhcp4: false

Step 5 – Apply the Configuration

Test the config without applying permanently:

sudo netplan try

If everything works, apply:

sudo netplan apply

Step 6 – Verify the Static IP

Confirm the new IP address:

ip addr show eth0

Step 7 – Test Connectivity

Verify you can reach the internet:

ping -c 4 1.1.1.1
ping -c 4 google.com

Conclusion

Your Ubuntu 24.04 LTS server now has a permanent static IP address configured via Netplan. Static IPs are essential for DNS records, firewall rules, and any service that other machines need to reach by address.