How to add IP Address on Ubuntu 18.04 using netplan? Print

  • 0

We can configure IP Address on ubuntu 18.04 using Netplan. It is a different method to add IP address than the older versions. Ubuntu 18.04 uses netplan to configure IP addresses. We will no longer use the /etc/sysconfig/network-interface to add IP addresses instead we will use a YAML file.  You will find the default configuration in /etc/netplan/ directory. 

  1. Find the default network configuration file using the below command.

    $ ls /etc/netplan/ 
  2. It is a default network configuration YAML file. Open it using the below command. 

    $ cat /etc/netplan/50-cloud-init.yaml
  3. You will see the ethernet card (enp0s1), you will need to 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) with below details.

  • IP address for enp0s1 : 192.168.0.1 (your ip address)

  • Gateway : 192.168.0.0

  • Netmask : 255.255.255.0

  • DNS servers : 8.8.8.8 and 8.8.4.4.

  1. You can use space to make the align properly as per image. 

  2. Save the file using Ctr+x.

  3. Now, apply the network configuration using below command. 

    $ sudo netplan apply
  4. Check your IP Address with the below command.

    $ ip addr

Was this answer helpful?

« Back
Sign up for a newsletter

chat