24.06.2025

How to Set a Static IP Address on Ubuntu 18.04 Using Netplan

How to configure static IP address in Ubuntu 18.04:

When setting up a server or working in a network-restricted environment, assigning a static IP address is often a crucial step. Unlike dynamic IP addresses assigned by DHCP, a static IP ensures that your system's address stays fixed across reboots — which is essential for remote access, port forwarding, and other network-related services. In this guide, we’ll walk you through the process of configuring a static IP address on Ubuntu 18.04 using Netplan, the default network configuration tool. Whether you're new to Ubuntu networking or need a quick refresher, this step-by-step tutorial will help you get your system properly configured.

List All Active Network Interfaces on Ubuntu

First, you need to identify the network interface you are going to configure. You can list all attached network interfaces on your system using the command as shown below:

Ip a

From the output of the above command, we have 3 interfaces attached to the Ubuntu system: 2 ethernet interfaces (one of them is docker) and the loopback interface. The ens33 ethernet interface has been configured to obtain IP address from DHCP. And we need to change it to static IP.

Set Static IP Address in Ubuntu 18.04

In this example, we will set up a static IP address for the ens33 network interface using the Netplan utility.

Netplan is a modern command-line tool for managing network settings, introduced in Ubuntu starting from version 17.10. It simplifies the configuration of network interfaces through a declarative YAML syntax. Netplan works in conjunction with system components like NetworkManager and systemd-networkd, which act as "renderers" — you can choose the one that best suits your environment.

Network settings are defined in YAML files located in the /etc/netplan/ directory. These configuration files allow you to specify parameters for all available network interfaces.

So the first thing to do is to check what configuration files do we have in /etc/netplan/
We can check this out by using the command:

ls /etc/netplan/

As we can see there is a configuration file called 50-cloud-init.yaml. We need to edit it to change configuration.

If there’s no configuration files in /etc/netplan/ you can use command as shown below to generate it:

sudo netplan generate

In addition, auto generated files may have different filenames on desktop, servers, cloud instantiations etc (for example 01-network-manager-all.yaml or 01-netcfg.yaml, 50-cloud-init.yaml, etc.), but all files under /etc/netplan/*.yaml will be read by netplan.

Open the netplan configuration file using your text editor as shown:

sudo nano /etc/netplan/50-cloud-init.yaml

Find your network interface name in there. It’s ens33 in this example.

As you can see there’s dhcp4: true = dchp for ipv4 is enabled.

To change that simply change the config like that:

Where:

The addresses property of an interface expects a sequence entry for example [192.168.14.2/24, “2001:1::1/64”] or [192.168.56.110/24, ] (see netplan man page for more information).

Important: don’t use tabs in this configuration file.

Save the file and exit. (to save file press Ctrl+O and then choose the filename and press Enter. To exit nano press Ctrl+X)

Then apply the recent network changes using the following command:

sudo netplan apply

If everything is ok you’ll not get any error messages.

Just check your ip configuration again with the command:

ip a

As you can see now the ens33 have an IP addresses as we configured before in yaml file.

Congratulations! You’ve successfully configured a network static IP addresses to your Ubuntu server.

FAQ: Configuring Static IP on Ubuntu 18.04

sudo netplan generate

If that doesn't work, it’s possible your system is using another method for network management (e.g., NetworkManager or legacy tools).

ip a

Your configured static IP should now be listed for the specified interface.