Set Static IP on Ubuntu Using Terminal

In this article, you will learn how to set Static IP on Ubuntu using Terminal.

There is a command-line utility that we are going to use to set the static IP address. The name of the utility is the Netplan and it is developed by Canonical. Basically, Netplan uses a YAML file to configure network interfaces.

Also, you can use the same method to configure an interface to get the IP dynamically using DHCP or set a static IP.

Set Static IP on Ubuntu 20.04 | 18.04

You have to open Terminal and go to the /etc/netplan directory. So here you can find the YAML configuration file that you will use to configure the IP address.

In my case, the YAML file is 01-network-manager-all.yaml and you can see the default settings in the below picture.

YAML FIle Of Netplan

If you are going to configure on Ubuntu Server then you can find the YAML file as 00-installer-config.yaml and below are the default settings.

Default YAML Settings in Ubuntu Server

As you want to configure the static IP, you have to copy and paste the below configuration. And also you must follow the spacing in the YAML file.

(remove the default settings from the YAML file and paste the below configuration)

  version: 2
        dhcp4: false
        addresses: []
          addresses: [,,]

Note: Change the ens33 with your network interface name. You can find the default interface name using the ifconfig command or ip a.

Now, save the file and run the netplan command. So it will save the changes.

sudo netplan apply

Also, you can check the new IP, using the below command

Static IP on Ubuntu
The output of the ifconfig command


ip a

There are many other ways to check the IP address.


In this tutorial, you learned to configure static IP on Ubuntu 20.04 | 18.04. But if you may get any errors or issues then write us a comment so we can help you.

Also, you may find the below article useful for you.

Leave a Reply