How to use the netplan command on Ubuntu

In Ubuntu 17.10, a new command-line network configuration tool was introduced known as “Netplan”. Netplan makes it simple to configure and manage network settings in your Ubuntu system. It also permits you the YAML abstraction for configuring a network interface. It interacts with the kernel through the systemd-networkd and NetworkManager daemons which are also known as renderers. You have to choose any one from both of them. Netplan reads the network configurations from “/etc/netplan/*.yaml” files, which can save the configuration settings for all network interfaces.

If you use the netplan command on Ubuntu, then It becomes easy to restart and change network settings. Netplan is also good for automation (humans and programs can read YAML). This write-up is focusing on how to use the netplan command on Ubuntu. Let’s begin:

How to list out all active network interfaces on Ubuntu

Any Linux system administrator should be familiar with the “ip” command, a powerful tool for configuring network interfaces. It can be used to assign and delete addresses and routes, put up or down interfaces, control ARP cache, and more. To get a list of active network interfaces on your system, utilize the “a” option in the ip command:

$ ip a

How to use netplan command for setting dynamic IP address on Ubuntu

This section will show you how to set a dynamic address on Ubuntu using the netplan command. But firstly, if the required YAML file does not exist in your system, then generate the renderer configuration file by writing out the below-given command in your terminal:

$ sudo netplan generate

Now, verify its presence on your system by listing out the “/etc/netplan/” files:

$ ls /etc/netplan/

Check the content of the network renderer configuration file:

$ cat /etc/netplan/*.yaml

Open up the “/etc/netplan/*.yaml” file in your nano editor:

$ sudo nano /etc/netplan/*.yaml

Now write out the below-given code in the /etc/netplan/*.yaml” file. We are going to set a dynamic IP address for our “enp0s3” network interface:

 version: 2
 renderer: networkd
     dhcp4: yes
     dhcp6: yes

In the above-given command:

  • dhcp4and dhcp6 are IPv4 and IPv6 DHCP properties.
  • enp0s3is the network interface name.

Press “CTRL+O” to save the changes in this file:

To apply modified network settings, utilize the below-given command in your terminal:

$ sudo netplan apply

Write out this command to confirm the IP address:

$ ifconfig -a

How to use netplan command for setting static IP address on Ubuntu

First of all, open up the “/etc/netplan/*.yaml” file in your nano editor:

$ sudo nano /etc/netplan/*.yaml

Then, write out the following code in the “/etc/netplan/*.yaml” file for setting a static IP address on your system:

  version: 2
  renderer: networkd
      dhcp4: no
      dhcp6: no
      addresses: []
              addresses: [,]

In the above-given command:

  • dhcp4and dhcp6 are IPv4 and IPv6 DHCP properties.
  • enp0s3 is the network interface name.
  • addresses contain the sequence of static addresses to the network interface.
  • gateway4contains default gateway’s IPv4 address.
  • nameserverscomprise a sequence of IP addresses for nameservers.

Press “CTRL+O” to save the changes we made in the file:

After that, apply the modified network settings by utilizing the below-given command:

$ sudo netplan apply

Now, check out if the configured “enp0s3” is connected to the local network and have a static IP address which we assigned earlier:

$ ifconfig -a

How to get more information about netplan on Ubuntu

To know more about the configuration options and information related to the netplan command, you can check out its man page:

$ man netplan

Follow this link to check out more configuration examples.


Netplan was introduced in Ubuntu 17.10 and is active by default in the latest releases, including Ubuntu 20.04. The purpose of this tool is to use YAML configuration files to abstract network interface configurations. Those configurations are then translated into networkd setups and NetworkManager for the given renderer. I hope the usage of netplan command for setting the static and dynamic addresses on Ubuntu will be clear for you after reading this article. To know more about trendy technology topics, keep following Linux Hint.

About the author

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.