How To Set Static IP Address on Ubuntu 26.04 LTS

Static IP Address on Ubuntu 26.04

Every Ubuntu server I have managed in production over the last ten years has had one thing in common: a static IP address. If you are trying to set a static IP address on Ubuntu 26.04 and you are not sure where to start, you are in the right place. A DHCP-assigned IP address changes every time your machine reboots or renews its lease, which breaks SSH sessions, DNS records, firewall rules, and anything else that depends on a predictable address. This guide walks you through three proven methods to configure a static IP on Ubuntu 26.04 LTS, explains exactly why each step matters, and shows you how to verify the result before walking away from your terminal.

What Is a Static IP Address and Why Does It Matter on Ubuntu 26.04?

A static IP address is a manually configured, fixed IP address that does not change between reboots, network reconnections, or DHCP renewals. It sits in contrast to a dynamic IP address, which a DHCP server hands out automatically and reclaims when the lease expires.

For personal laptops, dynamic IPs are fine. For anything running as a server, they are a liability.

Here is what breaks when your Ubuntu 26.04 server uses DHCP instead of a static IP:

  • SSH access: Your client connects to the server’s IP. If that IP changes overnight, your SSH session fails with a “connection refused” or “no route to host” error.
  • DNS records: An A record pointing to 192.168.1.100 becomes incorrect if DHCP assigns 192.168.1.115 on the next reboot.
  • Firewall rules: UFW and iptables rules that allow traffic to a specific IP stop working the moment that IP changes.
  • Monitoring agents: Tools like Prometheus node exporter, Zabbix agents, and Grafana dashboards that reference a server by IP will lose visibility entirely.
  • Docker and container networking: Containers that map host ports assume a consistent host IP. A changing host IP breaks bridge network routing rules.

Ubuntu 26.04 LTS uses Netplan as its default network configuration layer. Netplan reads YAML files from /etc/netplan/ and delegates the actual configuration work to a backend renderer, either systemd-networkd (common on servers) or NetworkManager (common on desktops). This means you do not edit the old /etc/network/interfaces file anymore. The configuration has moved, and knowing this saves you an hour of confusion.

Prerequisites for This Linux Server Tutorial

Before you run a single command, confirm the following:

  • Operating System: Ubuntu 26.04 LTS, either server or desktop edition
  • User Permissions: A user account with sudo privileges, or direct root access
  • Terminal Access: Either a local terminal, a physical console, or an active SSH session
  • Network Information Ready: You need your current IP range, subnet prefix, default gateway IP, and preferred DNS server addresses before editing any file
  • Out-of-Band Access (for remote servers): If you are on a cloud VPS or a remote machine, have your provider’s web console open in a separate browser tab before proceeding. A misconfigured network file can lock you out of SSH completely.

Sysadmin note: I have seen junior admins skip the out-of-band access step and end up locked out of production servers. Always have a fallback access method ready before touching network configuration files on any remote machine.

Step 1: Update Your System Before Making Any Network Changes

The first thing you should do before touching any network configuration is bring your system up to date. This is not just hygiene; on Ubuntu 26.04, some Netplan behavior and YAML schema validation improvements ship in point releases.

sudo apt update && sudo apt upgrade -y

What this does: apt update refreshes the package index from Ubuntu’s repositories. apt upgrade -y installs all available upgrades without prompting for confirmation. Running both together ensures Netplan, systemd-networkd, and NetworkManager are all at their latest versions before you make changes.

Why this matters: If you configure your network and later discover a Netplan bug that was already fixed in a patch release, you will waste time troubleshooting a problem that should not exist. Update first.

Step 2: Identify Your Network Interface Name

Ubuntu 26.04 uses the predictable network interface naming standard. Interface names look like ens33, enp2s0, or ens3 instead of the legacy eth0. You need the exact interface name because Netplan YAML files are case-sensitive and interface-name-specific.

ip link

Expected output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT
    link/ether 00:0c:29:ee:3a:cb brd ff:ff:ff:ff:ff:ff

What to look for: Ignore lo. It is the loopback interface used for internal OS communication. Your real network interface is the other entry, in this example ens33. Write it down. You will use it in every configuration file in the steps that follow.

Why this step matters: If you copy a tutorial that uses eth0 and paste that interface name into your Netplan YAML, Netplan will silently ignore the configuration and your DHCP lease will continue running unchanged. Always use the actual interface name from your own system.

Step 3: Gather Your Current Network Details

You cannot set a static IP correctly without knowing your current network range, gateway, and DNS configuration. Pull all of that with two commands.

Check Your Current IP Address and Subnet

ip addr show ens33

Look for the inet line in the output:

inet 192.168.1.105/24 brd 192.168.1.255 scope global dynamic ens33

This tells you:

  • Current IP: 192.168.1.105
  • Subnet prefix: /24 (which equals a subnet mask of 255.255.255.0)
  • The word dynamic confirms this is currently DHCP-assigned

Check Your Default Gateway

ip route

Expected output:

default via 192.168.1.1 dev ens33 proto dhcp src 192.168.1.105 metric 100
192.168.1.0/24 dev ens33 proto kernel scope link src 192.168.1.105

The default via line shows your gateway IP: 192.168.1.1. This is your router’s address. Write it down.

Why this matters: If you enter the wrong gateway IP in your static config, the server will be reachable within the local subnet but will have no path to the internet or any external network. You will be able to ping machines on 192.168.1.x but nothing outside that range.

Choose a static IP that is:

  1. Within your subnet (e.g., 192.168.1.100 if your range is 192.168.1.x)
  2. Outside your router’s DHCP pool range (check your router’s DHCP settings to confirm the range, typically 192.168.1.100-200)
  3. Not already used by another device on the network

Step 4: Configure a Static IP Address on Ubuntu 26.04 Using Netplan

This is the primary method for Ubuntu 26.04 LTS Server. Netplan is the recommended, persistent, and version-controllable way to configure a static IP address on Ubuntu 26.04 in a server environment.

Inspect the Existing Netplan File

cat /etc/netplan/00-installer-config.yaml

You will see something like this:

# This is the network config written by 'subiquity'
network:
  ethernets:
    ens33:
      dhcp4: true
      dhcp6: true
  version: 2

This confirms DHCP is currently active for both IPv4 and IPv6. You are going to replace this with your static configuration.

Edit the Netplan Configuration File

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

Replace the entire contents with the following. Substitute ens33 with your actual interface name, and replace the IP addresses with values from your own network:

network:
  version: 2
  ethernets:
    ens33:
      dhcp4: false
      dhcp6: false
      addresses:
        - 192.168.1.100/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses:
          - 1.1.1.1
          - 8.8.8.8
        search: []

Save the file with Ctrl+O, press Enter, then exit with Ctrl+X.

Line-by-line breakdown with the WHY for each:

  • dhcp4: false — Disables IPv4 DHCP. Without this, the DHCP client will continue running and may overwrite your static address the moment a lease renewal triggers. This is the most commonly missed setting.
  • dhcp6: false — Disables IPv6 DHCP. Unless you are explicitly managing IPv6 on this network, disable it to prevent the interface from picking up a random IPv6 global address.
  • addresses — Sets your chosen static IPv4 address. The /24 is CIDR notation and encodes both the IP and the subnet mask in a single value. /24 equals 255.255.255.0.
  • routes: to: default via: — This replaces the deprecated gateway4 key that was removed in newer Netplan versions. It defines the default route, meaning all traffic that does not match the local subnet gets forwarded to 192.168.1.1. Without this line, the server cannot reach anything outside its local network segment.
  • nameservers: addresses — Sets DNS resolver IPs. After switching from DHCP to static, the systemd-resolved service stops receiving DNS information from the DHCP server. Without explicit nameserver entries, apt will fail, ping google.com will return “Name or service not known,” and hostname resolution will be completely broken.
  • search: [] — Clears the DNS search domain list. On a server, leaving this populated with a stale domain name causes hostname resolution delays.

Secure the Netplan File Permissions

sudo chmod 600 /etc/netplan/00-installer-config.yaml

Why this matters: Ubuntu 26.04 will display a warning if Netplan YAML files have world-readable permissions. Network configuration files can expose your gateway IP, DNS servers, and IP addressing scheme. Restrict access to root only.

Step 5: Test and Apply the Netplan Configuration

Run a Safe Dry-Run Test First

sudo netplan try

What this does: netplan try applies your new configuration temporarily and starts a 120-second countdown. If your SSH session drops because the config is broken, the system automatically reverts to the previous working configuration after the countdown expires. This is the single most important safety step in this entire guide.

If the configuration is correct, press Enter to accept and make it permanent before the timer runs out.

Expected output on success:

Do you want to keep these settings?

Press ENTER before the timeout to accept the new configuration

Changes will revert in 119 seconds

Apply Permanently

sudo netplan apply

What this does: Commits the Netplan configuration permanently. After this command, the static IP is active, DHCP is stopped, and the configuration will persist across every reboot.

Why run apply after try: netplan try alone does not make the change permanent. If you close the terminal without pressing Enter during netplan try or without running netplan apply, the system reverts to DHCP on the next reboot.

Step 6: Verify Your Static IP Configuration Is Working

Never close the terminal before verifying. This step takes 60 seconds and saves you from discovering a problem hours later when a deployment fails.

Confirm the Static IP Is Assigned

ip addr show ens33

Expected output:

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP
    link/ether 00:0c:29:ee:3a:cb brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.100/24 brd 192.168.1.255 scope global ens33

Notice the word dynamic is gone. The address now shows scope global ens33 without a DHCP tag. That confirms the static IP is live.

Verify the Default Route

ip route

Confirm the output contains:

default via 192.168.1.1 dev ens33 proto static

The keyword proto static (instead of proto dhcp) confirms the route came from your Netplan configuration, not from a DHCP server.

Test DNS Resolution

ping -c 4 google.com

A successful ping to a hostname confirms that your DNS nameservers are resolving correctly. If this ping works, your full network stack is functional: IP assignment, routing, and DNS are all operational.

Method 2: Set Static IP Using nmcli on Ubuntu 26.04 Desktop

On Ubuntu 26.04 Desktop, NetworkManager is the default renderer, not systemd-networkd. Editing Netplan YAML files directly on a desktop system can create conflicts with the running NetworkManager daemon. Use nmcli instead.

List Active Connections

nmcli connection show

Expected output:

NAME                UUID                                  TYPE      DEVICE
Wired connection 1  a1b2c3d4-e5f6-7890-abcd-ef1234567890  ethernet  ens33

Apply the Static IP Configuration

sudo nmcli con mod "Wired connection 1" \
  ipv4.method manual \
  ipv4.addresses 192.168.1.100/24 \
  ipv4.gateway 192.168.1.1 \
  ipv4.dns "1.1.1.1,8.8.8.8"

Why ipv4.method manual is critical: Without this flag, NetworkManager reads your ipv4.addresses value but continues running DHCP in parallel. The DHCP lease will overwrite your static address at the next renewal. Setting the method to manual shuts DHCP off completely for this connection profile.

Restart the Connection to Apply Changes

sudo nmcli con down "Wired connection 1" && sudo nmcli con up "Wired connection 1"

This disconnects and reconnects the interface, forcing NetworkManager to read the updated connection profile. Verify with ip addr show ens33.

Method 3: Set Static IP Using the GNOME GUI

For users who prefer a graphical interface on Ubuntu 26.04 Desktop:

  1. Open Settings from the application menu.
  2. Navigate to Network (for wired) or Wi-Fi (for wireless).
  3. Click the gear icon next to your active connection.
  4. Select the IPv4 tab.
  5. Change the method from Automatic (DHCP) to Manual.
  6. Enter your Address, Netmask (e.g., 255.255.255.0), Gateway, and DNS values.
  7. Click Apply.
  8. Toggle the connection off and back on using the switch at the top of the connection settings panel.

Why toggle the connection off and on: GNOME Network Settings does not apply changes to a live connection until you reconnect. Skipping this step leaves the old DHCP-assigned IP active until the next reboot.

When to avoid the GUI method: Do not use this method on servers. GUI-based changes are harder to audit, cannot be version-controlled with Git, and are not reproducible across multiple machines without clicking through the same dialogs repeatedly. Netplan YAML files are the right choice for any server environment.

Troubleshooting: Common Errors When Setting a Static IP on Ubuntu 26.04

Error 1: Lost SSH Connectivity After netplan apply

Cause: You entered the wrong gateway IP or an IP address outside your subnet range.

Fix: Use your cloud provider’s web console or a physical terminal to access the machine. Open the Netplan file with sudo nano /etc/netplan/00-installer-config.yaml, correct the gateway and IP values, and run sudo netplan apply again.

Prevention: Always use sudo netplan try before sudo netplan apply on any remote server. The 120-second rollback timer exists exactly for this scenario.

Error 2: YAML Parse Error or “Invalid YAML” Message

Cause: You used tab characters for indentation instead of spaces. YAML parsers treat tabs and spaces as different characters, and Netplan rejects files with tab indentation entirely.

Fix: Open the file and check for tabs:

cat -A /etc/netplan/00-installer-config.yaml

Tab characters appear as ^I in the output. Replace every ^I with two spaces. Then validate the file:

sudo netplan generate

If this command returns no output, the YAML is valid.

Error 3: Static IP Works but No Internet Access

Cause: The routes block is missing or the gateway IP is incorrect. Without a default route, the server can communicate only within its local subnet.

Fix: Confirm the routes block is present and the gateway IP matches your router:

ip route

If the default via line is missing, re-edit the Netplan file and add:

routes:
  - to: default
    via: 192.168.1.1

Then run sudo netplan apply.

Error 4: DNS Not Resolving After Switching to Static IP

Cause: The nameservers block is missing from the Netplan YAML. When DHCP stops, the DNS information the DHCP server was supplying disappears too.

Fix: Add nameservers to your Netplan file and verify that /etc/resolv.conf points to systemd-resolved:

ls -la /etc/resolv.conf

It should be a symlink to /run/systemd/resolve/stub-resolv.conf. If it is a plain file, run:

sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

Then apply the Netplan configuration again.

Error 5: nmcli Changes Not Persisting After Reboot

Cause: The connection profile was modified but never reactivated. NetworkManager writes changes to disk only when the connection is brought back up.

Fix: Force the connection to cycle:

sudo nmcli con down "Wired connection 1" && sudo nmcli con up "Wired connection 1"

Then confirm the saved profile:

nmcli con show "Wired connection 1" | grep ipv4

Look for ipv4.method: manual in the output. If you still see auto, the modification command did not target the correct connection name.

Congratulations! You have successfully set up a static IP address. Thanks for using this tutorial to set a static IP address on Ubuntu 26.04 LTS (Resolute Raccoon) system. For additional help or useful information, we recommend you check the official Ubuntu website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!
r00t is a Linux Systems Administrator and open-source advocate with over ten years of hands-on experience in server infrastructure, system hardening, and performance tuning. Having worked across distributions such as Debian, Arch, RHEL, and Ubuntu, he brings real-world depth to every article published on this blog. r00t writes to bridge the gap between complex sysadmin concepts and practical, everyday application — whether you are configuring your first server or optimizing a production environment. Based in New York, US, he is a firm believer that knowledge, like open-source software, is best when shared freely.

Related Posts