{"id":2677,"date":"2018-11-06T14:43:58","date_gmt":"2018-11-06T14:43:58","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=2677"},"modified":"2018-11-07T14:08:27","modified_gmt":"2018-11-07T14:08:27","slug":"install-netplan-on-ubuntu-linux-hint","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/11\/06\/install-netplan-on-ubuntu-linux-hint\/","title":{"rendered":"Install Netplan on Ubuntu | Linux Hint"},"content":{"rendered":"<p>Netplan is a utility for configuring network interfaces on Linux. Netplan uses YAML files for configuring network interfaces. YAML configuration file format is really simple. It has clear and easy to understand syntax. Netplan works with traditional Linux networking system Systemd-networkd and Network Manager. With Netplan you can configure the network of your Ubuntu machines easier than ever before. Starting from Ubuntu 18.04 LTS, Ubuntu uses Netplan to configure network interfaces by default.<\/p>\n<p>In this article, I will show you how to install Netplan on Ubuntu 16.04 LTS and later, and how to use Netplan on Ubuntu. I will be using Ubuntu 18.04 LTS for the demonstration. But it should work the same way on every Ubuntu version where Netplan is installed. Let\u2019s get started.<\/p>\n<p>Netplan is available in the official package repository of Ubuntu. So, it is really easy to install. Netplan is not installed by default on Ubuntu 16.04 LTS. So, I am focusing on the installation method of Netplan on Ubuntu 16.04 LTS in this section. First, update the APT package repository cache with the following command:<\/p>\n<p>The APT package repository cache should be updated.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"842\" height=\"223\" \/><\/p>\n<p>Now, install Netplan with the following command:<\/p>\n<p>$ sudo apt install netplan<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"853\" height=\"94\" \/><\/p>\n<p>Netplan should be installed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1024\" height=\"488\" \/><\/p>\n<p>By default, Netplan is disabled on Ubuntu 16.04 LTS. You have to enable it manually. To enable Netplan, you have to create a file netplan in the \/etc\/default\/ directory and add ENABLED=1 to it.<\/p>\n<p>To do that, run the following command:<\/p>\n<p>$ echo &#8220;ENABLED=1&#8221; | sudo tee \/etc\/default\/netplan<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1090\" height=\"90\" \/><\/p>\n<p>\/etc\/default\/netplan file should be created.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1086\" height=\"124\" \/><\/p>\n<p>Now, reboot your computer with the following command:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1069\" height=\"85\" \/><\/p>\n<p>Netplan should be enabled.<\/p>\n<h2>Netplan Configuration Files:<\/h2>\n<p>On Ubuntu 18.04 LTS, the Netplan YAML configuration files are placed in the \/etc\/netplan\/ directory. To configure a network interface, you have to create or modify required YAML files in this directory. YAML configuration files has the .yaml extension. The default Netplan YAML configuration file \/etc\/netplan\/50-cloud-init.yaml is used to configure network interfaces using Netplan.<\/p>\n<p>On Ubuntu 16.04 LTS, the configuration files are placed in the \/etc\/plan directory and the default configuration file is \/etc\/plan\/netplan-acl.<\/p>\n<p>Make sure you modify the correct configuration file depending on the version of Ubuntu you\u2019re using.<\/p>\n<h3>Configuring Network Interface via DHCP with Netplan:<\/h3>\n<p>In this section, I will show you how to configure a network interface via DHCP on Ubuntu with Netplan. First, find the network interface name that you want to configure with the following command:<\/p>\n<p>As you can see, I have one network interface card (NIC) installed on my Ubuntu 18.04 LTS machine and the network interface name is ens33. It does not have any IP address configured right now. Let\u2019s use Netplan to configure it via DHCP.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"892\" height=\"212\" \/><\/p>\n<p>To configure the network interface ens33 via DHCP using Netplan, open the default Netplan configuration file on Ubuntu 18.04 LTS \/etc\/netplan\/50-cloud-init.yaml with the following command:<\/p>\n<p>$ sudo nano \/etc\/netplan\/50-cloud-init.yaml<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"591\" height=\"43\" \/><\/p>\n<p>You should see the following window.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"968\" height=\"192\" \/><\/p>\n<p>Now add the following lines in the network section.<\/p>\n<p>ethernets:<br \/>\nens33:<br \/>\ndhcp4: yes<\/p>\n<p>Here, dhcp4: yes means, use DHCP for IPv4 protocol to configure the network interface ens33.<\/p>\n<p><u>NOTE:<\/u> The indentations are really useful. Make sure you indent each line correctly. It will make the syntax clearer and comfortable to the eye.<\/p>\n<p>Finally, the configuration file should look something like this.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"913\" height=\"262\" \/><\/p>\n<p>Now, press &lt;Ctrl&gt; + x and then press y followed by &lt;Enter&gt; to save the file.<\/p>\n<p>The good thing about Netplan is that before you apply the changes, you can make sure the configuration file has no typos or any other mistakes with the following command:<\/p>\n<p>Now press &lt;Enter&gt;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"848\" height=\"200\" \/><\/p>\n<p>If everything is alright, you should see Configuration accepted message as marked in the screenshot below.<\/p>\n<p>If there\u2019s any problem with the configuration file, you will see appropriate error messages here.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"800\" height=\"240\" \/><\/p>\n<p>This feature will surely help you to avoid complex hard to track future problems with Netplan configuration files. Finally, apply the changes permanently using Netplan with the following command:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"826\" height=\"62\" \/><\/p>\n<p>As you can see, the network interface ens33 is configured via DHCP.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1140\" height=\"252\" \/><\/p>\n<h3>Setting Up Static IP Address with Netplan:<\/h3>\n<p>If you want to set up a static IP on your network interface using Netplan, then this section is for you. You can manually set the IP address, name server, gateway etc. of your network interface using Netplan. Let\u2019s say, you want to configure your network interface ens33 as follows:<\/p>\n<p>Static IP address: 192.168.10.33<br \/>\nSubnet mask: 255.255.255.0<br \/>\nGateway: 192.168.10.1<br \/>\nDNS server: 192.168.10.1<\/p>\n<p>First, check the network configuration of ens33 network interface with the following command:<\/p>\n<p>This is to help you verify that the network interface settings really changed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"988\" height=\"267\" \/><\/p>\n<p>Now, edit the Netplan YAML configuration file \/etc\/netplan\/50-cloud-init.yaml with the following command:<\/p>\n<p>$ sudo nano \/etc\/netplan\/50-cloud-init.yaml<\/p>\n<p>If you\u2019ve followed me throughout the article, then the configuration file should be like this. Now, remove the line as marked in the screenshot below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"923\" height=\"236\" \/><\/p>\n<p>And type in the lines as marked in the screenshot below.<\/p>\n<p><u>NOTE:<\/u> Remember, indentation is essential for YAML files. If you forget to indent correctly, Netplan will not let you apply the configuration file. So, you must indent every step of the YAML configuration file as shown in the screenshot below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1026\" height=\"311\" \/><\/p>\n<p>Now, press &lt;Ctrl&gt; + x and then press y followed by &lt;Enter&gt; to save the file.<\/p>\n<p>Now, check whether there\u2019s any error in the configuration file with the following command:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"771\" height=\"62\" \/><\/p>\n<p>press &lt;Enter&gt;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"826\" height=\"200\" \/><\/p>\n<p>As you can see, the configuration file is accepted.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"829\" height=\"233\" \/><\/p>\n<p>Finally, apply the configuration file with the following command:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"746\" height=\"60\" \/><\/p>\n<p>As you can see, the IP address is changed as expected.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"1002\" height=\"261\" \/><\/p>\n<p>The gateway is also set correctly.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"752\" height=\"126\" \/><\/p>\n<p>The DNS server is set correctly as well.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxhint.com\/image\/gif;base64,R0lGODdhAQABAPAAAP\/wAAACwAAAAAAQABAEACAkQBADs=\" alt=\"\" width=\"865\" height=\"191\" \/><\/p>\n<p>So, that\u2019s how you install and use Netplan on Ubuntu to configure network interfaces using YAML files. If you want to learn more about Netplan, please visit the official website of Netplan at <a href=\"https:\/\/netplan.io\">https:\/\/netplan.io<\/a>. Thanks for reading this article.<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/install_netplan_ubuntu\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Netplan is a utility for configuring network interfaces on Linux. Netplan uses YAML files for configuring network interfaces. YAML configuration file format is really simple. It has clear and easy to understand syntax. Netplan works with traditional Linux networking system Systemd-networkd and Network Manager. With Netplan you can configure the network of your Ubuntu machines &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/11\/06\/install-netplan-on-ubuntu-linux-hint\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Install Netplan on Ubuntu | Linux Hint&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2677","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/2677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=2677"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/2677\/revisions"}],"predecessor-version":[{"id":2810,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/2677\/revisions\/2810"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=2677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=2677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=2677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}