Configuring Static IPv4 Address using Netplan on Ubuntu 18.04 and Up

This guide is applicable only for KVM based VPSes, for OpenVZ based VPSes please click here

From Ubuntu 18.04, a switch was made to configure network using NetPlan written in YAML. In this article, we will learn how to configure networking in newer versions of Ubuntu, such as Ubuntu 18.04, 20.04, 22.04 and so on using Netplan.

To Find The Network Gateway and Netmask

To find out the IPv4 Address assigned to you, login to CrownPanel and navigate to Manage Network tab.

Configuring IPv4

First, we find the Network interface name,

ip a

Here's my IP


In this example, the system is configured with the network interface name as ens3, this might not be the case with your system, please verify the system network interface name with the ip a command above before proceeding with the guide below!

We will see how we can configure the IPv4,

A side note on this, YAML is strict on indentation so we will use 2 spaces through out the guide.

Using your favourite editor, edit the file present in /etc/netplan/ directory.

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

Initially, the network is configured to DHCP.

      dhcp4: true
  version: 2

We will make it Static by changing to

  version: 2
  renderer: networkd
        addresses: [,]
        - to: default

Under addresses, we've added the Main IP of the server followed by it's prefix. If your netmask is "", then use /24 prefix.

You can find more info on how to use the right prefix here.

In routes, we've put the gateway IP of the IP block. This can be found in the "Manage Network" page in CrownPanel.

For nameservers, we are using google's public DNS.

You can also try CloudFlare's public DNS as well.

Save and exit the configuration.

Run the following command to test the changes.

netplan try

If the configuration fails, changes will be reverted in 120 seconds.

If you are able to view the countdown and connected to the server, this means the configuration is correct. Just press Enter key to save and apply the changes.

This should effectively configure the IPv4 from DHCP to Static and to test if the network is still up.

root@vps:~# ping
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=57 time=0.515 ms
64 bytes from icmp_seq=2 ttl=57 time=0.537 ms
64 bytes from icmp_seq=3 ttl=57 time=0.522 ms

This concludes our topic of configuring static IPv4 on Ubuntu systems.

If you can not configure and facing technical difficulties, kindly reach out to us via Support Ticket.