[Updated on Date: 2021-01-30] A static IP is an IP address that is fixed and does not change. You can set it for your devices that use an IP address to be configured for having a static IP address. Since the network configuration is controlled and managed by netplan in Ubuntu 20.04, join us to review how to set IP static on ubuntu 20.04 LTS Server with netplan. Netplan enables configuring networking on a system via YAML files easily. And processes the YAML and generates the required configurations for either Network Manager or systemd-network the system’s renderer. To buy your own Linux VPS visit Eldernode and find the best suitable package due to your needs.
To let this tutorial work better, please consider the below Prerequisites:
A non-root user with sudo privileges.
To set up, follow our Initial server setup on Ubuntu 20.04.
Table of Contents
Tutorial Set IP static on Ubuntu 20.04 LTS Server with netplan
Using netplan utility as a new command-line network configuration helps you to manage and configure network settings easily in Ubuntu systems.
How to check Interface name
In the first step, you need to check all interfaces on the Ubuntu 20.04 LTS server. Enter the below command for getting the Network Interface Controller name.
When you enter the command, you can see your interface name. You need the name for network configuration later.
How to Set the IP address on Ubuntu 20.04 server
Go to /etc/netplan directory and check the name of the YAML file.
After that, you can use the ls command to see the YAML file.
It is time to set IP static on Ubuntu 20.04 LTS Server.
Sudo nano 00-installer-config.yaml
Remember: Do not forget to edit your yaml file.
Type your Static IP and other information like this
network ethernets: ens160: dhcp4: no addresses: [192.168.100.120/24] gateway4: 192.168.100.1 nameservers: addresses: [22.214.171.124, 126.96.36.199] dhcp6: no version: 2
Please attention below picture, you will see some space and some rules. If you do not consider rules, netplan can not detect your configuration.
After adding IP static and other information on the file, save, and exit.
Point: you can save and exit with Ctrl + x key and press Enter key twice.
Apply configuration with the following command.
sudo netplan apply
Now you can check Network configuration by ping your IP or ip addr command.
Also, you could see the video on the Eldernode Youtube channel.
In this article, you learned how to Set IP static on Ubuntu 20.04 LTS Server with netplan. From now on you can look at the bigger infrastructure by using the static IP to avoid network problems. In case you are interested in learning more, find our related article on How to find server public IP Address in Linux terminal.