On ubuntu 18.04 LTS, the network configuration is now managed by NetPlan by default. The network configuration files are saved in /etc/netplan/ directory with a .yaml extension.
When you install the Ubuntu 18.04 server version, the default NetPlan yaml file is located at /etc/netplan/50-cloud-init.yaml, by default it uses DHCP method to get ip address configuration for the interface.
What is NetPlan?
Netplan is a utility for easily configuring networking on a linux system. You simply create a YAML description of the required network interfaces and what each should be configured to do.
In this quick tutorial, we are going to show you how to setup a static IP address on ubuntu 18.04 LTS using NetPlan tool
– Let’s rename the 50-cloud-init.yaml and create our new configuration file named 01-netcfg.yaml, In this example we are going to configure a static IP address, where the IP is 192.168.1.151, subnet mask 24 (255.255.255.0), default gateway is 192.168.1.254 and nameservers 192.168.1.254 and 22.214.171.124 on the network interface enp3s0 .
$ sudo mv /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.org $ sudo vi /etc/netplan/01-netcfg.yaml network: version: 2 renderer: networkd ethernets: enp3s0: addresses: - 192.168.1.151/24 gateway4: 192.168.1.254 nameservers: search: [yallalabs.com, yallalabs.local] addresses: [192.168.1.254, 126.96.36.199]
– Save the file and exit. Then apply the recent network changes using following netplan command.
$ sudo netplan apply
We hope this tutorial was enough Helpful. If you need more information, or have any questions, just comment below and we will be glad to assist you!
PS. If you like this post please share it with your friends on the social networks using the buttons below.Thanks.