Today we are going to see how we can set an IP address using netplan utility in Ubuntu linux.
Ubuntu 18.04 LTS comes with netplan utility installed and recommend to make changes in IP settings using netplan utility.
Netplan uses YAML format script to configure interfaces. and from this scripts it will generate all necessary configuration files.
Netplan reads scripts from /etc/netplan/*.yaml
Check for .yaml file in /etc/netplan/ and edit it using text editor like vi, vim or nano.
If file is not there you can generate using
sudo netplan generate
Now edit file,
$ sudo nano /etc/netplan/1-network-manager-all.yaml
and paste below code in the file.
# This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: ens33: dhcp4: no dhcp6: no addresses: [192.168.1.2/24] gateway4: 192.168.1.1 nameservers: addresses: [22.214.171.124,126.96.36.199]
Make sure to replace “addresses”, “gateway4” “addresses” under “nameservers” according to your preference.
Exit and apply changes using below command.
sudo netplan apply
You can check ip settings using
To know more about netplan visit https://netplan.io/