How to set Static IP on Ubuntu 20.04 | 18.04
To set a static IP address, we will use a command-line utility. The utility is called Netplan and was developed by Canonical. Basically, Netplan configures network interfaces with YAML files. It’s possible to configure an interface using the same technique to get a dynamic IP or set a static IP with the same method.
In this article, we will explain how to set static IP on Ubuntu 20.04 | 18.04
Step 1: Getting your system up and running
- Sign in to your system or register a newly created one by logging in to your VPSie account.
- Connect by SSH using the credentials we emailed you.
- Once you have logged into your Ubuntu instance, run these commands to update your system.
apt-get update && apt-get upgrade -y
Step 2: Set Static IP
Using Terminal, open the /etc/netplan directory. This is where you will find the YAML configuration file you will use to change the IP address.
I have a YAML file named 00-installer-config.yaml. If you’re configuring a static IP address, copy the below configuration and paste it. The YAML file must also be padded correctly.
network: version: 2 ethernets: ens33: dhcp4: false addresses: [18.104.22.168/24] gateway4: 1162,220.13.248 nameservers: addresses: [22.214.171.124, 126.96.36.199, 188.8.131.52]
Run the netplan command after you have saved the file. This will make the changes permanent.
sudo netplan apply
If you would like to check the new IP address, you can use the below command, The IP address can also be checked in many other ways, Here we are using “ifconfig“
That’s it! Thanks for reading! I hope it was informative for you!