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
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.
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
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.
My configuration file is named so
00-installer-config.yamlyou can use an editor
vito edit the file.
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: - 126.96.36.199/22 #IP address and Netmask of IP gateway4: 188.8.131.52 #Gateway nameservers: addresses: - 184.108.40.206 #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>
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.
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.
Then you scroll down to the bottom and configure DNS, here I configure Google DNS as 220.127.116.11. If you configure more DNS ranges, use commas
,and add. For example is
18.104.22.168, 22.214.171.124. After successfully entering, click Apply to apply the changes.
Now turn on the connection by clicking the Button below to Turn it On/Off .
To check if the device has successfully configured the Network, I will open the Terminal window and PING out. Here I PING 126.96.36.199 and the result was received successfully.
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.
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.