{"id":1855,"date":"2021-07-23T14:45:52","date_gmt":"2021-07-23T21:45:52","guid":{"rendered":"https:\/\/jim-zimmerman.com\/?p=1855"},"modified":"2021-12-17T14:27:06","modified_gmt":"2021-12-17T21:27:06","slug":"ubuntu-18-x-netplan-to-set-static-ip-address","status":"publish","type":"post","link":"https:\/\/jim-zimmerman.com\/?p=1855","title":{"rendered":"Ubuntu 18.x\/20.x &#8211; netplan to set static IP address"},"content":{"rendered":"<p>Here we go again. A completely different way to configure the network using netplan. I used the following on an Ubuntu 18.x LTS server to configure the static IP address:<\/p>\n<p>$ cd \/etc\/netplan<\/p>\n<p>If this directory, there will be a yaml file.  I have seen this have a couple different names, but it has always been the only file in the directory.  In this case, the file was named: 00-installer-config.yaml<\/p>\n<p>If you brought the machine using DHCP, you need to change the &#8220;dhcp4: yes&#8221; line to &#8220;dhcpv: no&#8221;.  Below, is an example setting the IP address, mask via the CIDR designation (subnet bits) after the IP address, the gateway, the nameservers and a search domain.  <\/p>\n<p>Note: the format (indentation) of the lines in the file are important.<\/p>\n<p>$ sudo vi 00-installer-config.yaml<br \/>\n&#8230;<\/p>\n<blockquote><p>network:<br \/>\n  ethernets:<br \/>\n    ens160:<br \/>\n      dhcp4: no<br \/>\n      addresses: [aaa.bbb.ccc.ddd\/mm]<br \/>\n      gateway4: eee.fff.ggg.hhh<br \/>\n      nameservers:<br \/>\n        addresses: [www.xxx.yyy.zzz, mmm.nnn.ooo.ppp]<br \/>\n        search: [my.domain, my.otherdomain]<br \/>\n  version: 2<\/p><\/blockquote>\n<p>For Ubuntu 20.x:<\/p>\n<blockquote><p>network:<br \/>\n  ethernets:<br \/>\n    ens32:<br \/>\n      addresses:<br \/>\n      &#8211; aaa.bbb.ccc.ddd\/mm<br \/>\n      gateway4: eee.fff.ggg.hhh<br \/>\n      nameservers:<br \/>\n        addresses:<br \/>\n        &#8211; www.xxx.yyy.zzz<br \/>\n        &#8211; mmm.nnn.ooo.ppp<br \/>\n        search:<br \/>\n        &#8211; my.domain<br \/>\n  version: 2<\/p><\/blockquote>\n<p>Note: Make sure you do the following from the console, if modifying the IP address.<br \/>\nApply the configuration:<br \/>\n$ sudo netplan apply<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here we go again. A completely different way to configure the network using netplan. I used the following on an Ubuntu 18.x LTS server to configure the static IP address: $ cd \/etc\/netplan If this directory, there will be a yaml file. I have seen this have a couple different names, but it has always [&#038;hellip<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[503,132],"class_list":["post-1855","post","type-post","status-publish","format-standard","hentry","category-documentation","tag-netplan","tag-ubuntu"],"share_on_mastodon":{"url":"","error":""},"_links":{"self":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1855"}],"version-history":[{"count":5,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1855\/revisions"}],"predecessor-version":[{"id":1887,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=\/wp\/v2\/posts\/1855\/revisions\/1887"}],"wp:attachment":[{"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jim-zimmerman.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}