Instructions for configuring Static IP on Ubuntu via Netplan

Continuing today’s article, I want to share with you how to configure Static IP on Ubuntu including Ubuntu server and Ubuntu Desktop. If you are used to configuring with Windows or have configured through servers running RHEL/CentOS, then for Ubuntu the configuration will be completely different. From configuration files and executable commands are different.

Therefore, I wrote a short article that I hope will help you configure quickly and successfully. With Ubuntu, you will configure it via Netplan. So what is Netplan? Let’s do some preliminary research before we do it.

What is Netplan?

Resulted from the release of the Netplan 17:10 is a network management tool default on Ubuntu instead of configuration files interfacein /etc/network/interfaceas before.

Netplan is used to configure the YAML syntax and to configure the network with Netplan you need to create a YAML configuration file corresponding to the network card you use. Netplan currently supports 2 renderers NetworkManager and Systemd-networkd . Where NetworkManage is mainly used on desktops and Systemd-networkd is used on servers without GUI.

In this article, I will guide you to configure on Ubuntu Server and Ubuntu Desktop as follows. Let’s follow and do it with us.

Configuration on Ubuntu Server.

To configure, you need to determine what is the name of the ethernet network card you are using. With Ubuntu, enter the command ip linkto check.

ip link

Right now the system will print out the network card information, as in the picture below I have a Lookpack card and the main card will be ens18.

Configure IP Static on Ubuntu

Now open the configuration file to start configuring the IP. The netplan configuration files will be in the path /etc/netplanand the files with the extension will be .yamlas shown below.

Configure IP Static on Ubuntu

My configuration file is named so 00-installer-config.yamlyou can use an editor vito edit the file. vi 00-installer-config.yaml.

One thing you need to know in this configuration file is that each Netplan file will start with the keyword network and have at least 2 mandatory elements that are.

  • version: Version parameter of the network
  • device type: Can be ethernets, bonds, bridges, or vlans

Below is the entire configuration in my file with the following line comment #.

# This is the network config written by 'subiquity' 
network: 
  ethernets: 
    ens18 : #Network card 
      addresses: 
      - 45.252.249.114/22 #IP address and Netmask of IP 
      gateway4: 45.252.248.1 #Gateway 
      nameservers: 
        addresses: 
        - 8.8.8.8 #Nameserver 
  version: 2 #network version

After you have finished adjusting the configuration file, enter the following command to apply the change and verify the change.

netplan apply
ip addr show dev <tên interface="">
    </tên>
Configure IP Static on Ubuntu

To check if I’m online, I ping out the internet. Here I PING to google.com and the result was as successful as the picture.

Configuration on Ubuntu Desktop

For Ubuntu Desktop has an intuitive interface and to configure you follow the steps with the attached picture I describe.

First, go to Settings, select Network and click on the Gear icon to configure the network.

Configure IP Static on Ubuntu

Next, select the IPv4 tab and select Manual and configure the Address box as follows.

  • Address: Please enter your IP.
  • Netmask: Please enter the Netmask address, if you do not know what the netmask address is, visit the link http://jodies.de/ to check.
  • Gateway: Enter your Gateway address.
Configure IP Static on Ubuntu

Then you scroll down to the bottom and configure DNS, here I configure Google DNS as 8.8.8.8. If you configure more DNS ranges, use commas ,and add. For example is 8.8.8.8, 1.1.1.1. After successfully entering, click Apply to apply the changes.

Configure IP Static on Ubuntu

Now turn on the connection by clicking the Button below to Turn it On/Off .

Configure IP Static on Ubuntu

To check if the device has successfully configured the Network, I will open the Terminal window and PING out. Here I PING 8.8.8.8 and the result was received successfully.

Configure IP Static on Ubuntu

To make sure you can access the websites you have made, open your browser and enter the website name. As you can see the result below is already successful.

Epilogue

So you have just completed the steps to configure Network on Ubuntu already. It’s easy when you follow the documentation right. Through this tutorial on configuring IP Static on Ubuntu, we hope to help you gain more knowledge in configuring and operating your own server .

Hope you are succesful.

On this page