{"id":291,"date":"2018-07-20T21:07:22","date_gmt":"2018-07-20T21:07:22","guid":{"rendered":"https:\/\/projects-42.nl\/?p=291"},"modified":"2018-07-20T21:11:24","modified_gmt":"2018-07-20T21:11:24","slug":"network-configuration-in-ubuntu-server-18-04","status":"publish","type":"post","link":"https:\/\/projects-42.nl\/index.php\/2018\/network-configuration-in-ubuntu-server-18-04\/","title":{"rendered":"Network configuration in Ubuntu Server 18.04"},"content":{"rendered":"<p>As you might have heard, Ubuntu (server) 18.04 uses a new network configuration system named Netplan.<\/p>\n<p>Well, Netplan is not entirely new, it was introduced in Ubuntu 17:10 but I did not pay to much attention to it at the time because I prefer the Ubuntu LTS editions.<\/p>\n<p>The first big change you will notice is the location the where the network configuration is stored. If you grab the default image form the Ubuntu website, there will be a file named &#8220;50-cloud-init.yaml&#8221; which is located in &#8220;\/etc\/netplan\/&#8221;. The funny part is, this is not the only place you can store network configuration files. A <a href=\"https:\/\/blog.ubuntu.com\/2017\/12\/01\/ubuntu-bionic-netplan\">blog post on the Ubuntu blog<\/a> shows there are 3 locations available for storing network configurations (in order of importance):<\/p>\n<ul>\n<li>\/run\/netplan\/*.yaml<\/li>\n<li>\/etc\/netplan\/*.yaml<\/li>\n<li>\/lib\/netplan\/*.yaml<\/li>\n<\/ul>\n<p>You can place any number of .yaml files in each of the above directory&#8217;s, where the lowest alphabetical filename will be the leading one (A*.yaml before B*.yaml). If a filename is used in multiple directory&#8217;s, the one in the most important directory will be the leading one.<\/p>\n<p>Did I mention the files are YAML? Great lets use an indentation dependent format, what could possibly go wrong when using nano or VI without formatting and validation tools.<\/p>\n<p>Needles to say, this might become a bit confusing when you need to troubleshoot a system you did not configure or maintain.<\/p>\n<p>But enough of my ranting, lets she how we can configure a static IP address.<\/p>\n<p>Luckily Canonical did set up a webpage to provide information about Netplan (<a href=\"https:\/\/netplan.io\">https:\/\/netplan.io<\/a>) this page also contains a neat set of Netplan <a href=\"https:\/\/netplan.io\/examples\">examples.<\/a><\/p>\n<p>The main page also explains that the default configuration location should be in &#8220;\/etc\/netplan\/&#8221; there are no guidelines about the names for the configuration files, so you can &#8220;go ham&#8221; on those.<\/p>\n<p>The configuration itself is kind of straight forward here is a basic IPv4 configuration with 2 name servers:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">network:\r\n  ethernets:\r\n    eth0:\r\n      addresses:\r\n        - 192.168.0.2\/24\r\n      gateway4: 192.168.0.1\r\n      nameservers:\r\n          addresses: [192.168.0.1,8.8.8.8]\r\n\r\n<\/pre>\n<p>If you want IPv4 DHCP instead see below (for IPv6 set &#8220;dhcp6&#8221; to true and &#8220;dhcp4&#8221; to false):<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\">network:\r\n  version: 2\r\n  ethernets:\r\n    eth0:\r\n      dhcp4: true\r\n      dhcp6: false\r\n\r\n<\/pre>\n<p>Don&#8217;t forget to apply the configuration when your done<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">sudo netplan apply<\/pre>\n<p>If you need a more advanced configuration like more addresses on one interface or VLANs, check out the\u00a0comprehensive example page on the Netplan website (<a href=\"https:\/\/netplan.io\/examples\">https:\/\/netplan.io\/examples<\/a>).<\/p>\n<p>They did a good job showing of a lot of differed possibility&#8217;s \ud83d\ude42<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As you might have heard, Ubuntu (server) 18.04 uses a new network configuration system named Netplan. Well, Netplan is not entirely new, it was introduced in Ubuntu 17:10 but I did not pay to much attention to it at the time because I prefer the Ubuntu LTS editions. The first big change you will notice [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":292,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[63,61,62,21,60],"class_list":["post-291","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general-ict","tag-18-04","tag-bionic-beaver","tag-netplan","tag-ubuntu","tag-ubuntu-18-04"],"_links":{"self":[{"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/posts\/291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/comments?post=291"}],"version-history":[{"count":7,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/posts\/291\/revisions"}],"predecessor-version":[{"id":299,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/posts\/291\/revisions\/299"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/media\/292"}],"wp:attachment":[{"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/media?parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/categories?post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/projects-42.nl\/index.php\/wp-json\/wp\/v2\/tags?post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}