How To Set A Static IP Address On Linux Ubuntu Server 20.04 LTS (Focal Fossa).

When Ubuntu Server 18.04 was released, it came with some new improvements on how administrators work with the Ubuntu OS. One significant change was the manner by which network configuration is done. In older versions of ubuntu if you wanted to change or set a static IP address you had to edit the /etc/network/interfaces configuration file. However with newer versions of ubuntu, a combination of the NETPLAN configuration utility and YAML configuration files is used. So essentially the YAML files contain network configuration parameters such as the IP Address to use, SUBNET MASK and DEFAULT GATEWAY and the NETPLAN utility reads this information and generates backend specific configuration files that will be used by the system daemons responsible for network functionality in Ubuntu. Click on the button below to watch the video tutorial
REQUIREMENTS
In order to complete this tutorial successfully the following items are required. Please ensure to have these items available before taking implementation action on this tutorial:
1) A physical server , desktop or virtual machine running linux ubuntu server 20.04 LTS
2) An ubuntu user account with access rights to make network configuration changes
3) A network interface card.
OVERVIEW
1) Connect to the ubuntu server via SSH or directly using a monitor, and keyboard and login using your ubuntu credentials
2) Run the command ip -a to check the current ip address and identify the network interface that you would like to set a static IP on.
3) Go into the etc/netplan folder and set a static ip address in a YAML configuration file.
4) Run the NETPLAN -APPLY command to apply changes and use the ping command to test changes.
Step 1: Check the current IP configuration.
1) The first step is to check the current IP configuration that has been applied to the network interfaces on the server as well as the name of the network interface that can be used to set a static IP address.
Run the command : ip a
The image on the right shows that the network configuration was applied to the enp0s3 network interface and this is the interface that is connected to the network and should get the static IP assignment.

2) Next, if you go into the /etc/netplan directory there should be a file with a .yaml file extension. If it doesn’t exist, create it with the command:.
sudo netplan generate
Open the .yaml file using the command : nano yaml-config-file.yaml and you should see some configuration that includes the following details:
# This is the network config written by ‘subiquity’
network:
ethernets:
enp0s3:
dhcp4: true
version: 2

3) Next, type in the desired IP address, gateway, and DNS nameservers in the format shown below and ensure that your indentation is consistent, otherwise, Netplan will give out errors when reading the YAML file :
dhcp4: no
dhcp6: no
addresses: [192.168.56.110/24, ]
gateway4: 192.168.56.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]

4) The next step is to apply changes by running the command:
netplan apply
When you run the command, netplan should not generate any error message, If you see an error message please check the indentation of the text in the configuration file again.
To see sample configurations of netplan YAML files and to find out more about NETPLAN click HERE
