How to Add an IP Address on Ubuntu 18.04 using Netplan? Print

  • 0

We can configure IP Addresses on Ubuntu 18.04 using Netplan while adding an IP Address in the older versions is a different method. 

Ubuntu 18.04 uses Netplan to configure IP Addresses. Therefore, we will use a YAML file instead of the /etc/sysconfig/network-interface to add IP Addresses.  

You will find the default configuration in the /etc/netplan/ directory. 

1. Find the default network configuration file using this command -  

$ ls /etc/netplan/ 

2. It is a default network configuration YAML file.
    Open it using this command – 

$ cat /etc/netplan/50-cloud-init.yaml

3. You will see the ethernet card (enp0s1); you must configure the IP Address here.

4. Take the backup of the 50-cloud-init.yaml file before making any changes.

$ sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bak

5. Configure IP Address on ethernet card (enp0s1) using the below details – 

  • IP address for enp0s1: (your IP Address)
  • Gateway:
  • Netmask:
  • DNS servers: and

6. You can use space to make the alignment as per the shown image -

7. Save the file using Ctrl + x.

8. Apply the network configuration using this command –  

$ sudo netplan apply

9. Check your IP Address with this command – 

$ ip addr


Was this answer helpful?

« Back