{"id":108910,"date":"2021-04-08T07:57:12","date_gmt":"2021-04-08T00:57:12","guid":{"rendered":"https:\/\/www.harianaceh.co.id\/?p=108910"},"modified":"2022-10-06T04:24:38","modified_gmt":"2022-10-05T21:24:38","slug":"steps-how-to-configure-a-static-ip-address-on-ubuntu-20-04-operating-system","status":"publish","type":"post","link":"https:\/\/www.harianaceh.co.id\/2021\/04\/08\/steps-how-to-configure-a-static-ip-address-on-ubuntu-20-04-operating-system\/","title":{"rendered":"Steps How to Configure a Static IP Address on Ubuntu 20.04 Operating System"},"content":{"rendered":"<p>It is a good idea to set a static or fixed <a title=\"ip address\" href=\"https:\/\/www.harianaceh.co.id\/tag\/ip-address\/\">ip address<\/a> to a server so that you can guarantee that the machine will always have the same ip address to make it easier to connect to.<\/p>\n<p>We prefer to set a <a title=\"static ip\" href=\"https:\/\/www.harianaceh.co.id\/tag\/static-ip\/\">static ip<\/a> dynamically using my dhcp server but if you prefer to add a static IP address then this can easily be done using the following process:<\/p>\n<h3><span id=\"Set_a_static_IP_address\" class=\"ez-toc-section\"><\/span>Set a static IP address:<\/h3>\n<h4><span id=\"Find_the_correct_interface_name\" class=\"ez-toc-section\"><\/span>Find the correct interface name:<\/h4>\n<p>Open a terminal and run the following command:<\/p>\n<pre class=\"wp-block-code\"><code>ip a<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108914\" src=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-1.png\" alt=\"\" width=\"666\" height=\"295\" \/><\/a><\/p>\n<p>In the example above the network card is eth0 as it is the only interface with an ip address.<\/p>\n<h4><span id=\"Backup_the_networking_file\" class=\"ez-toc-section\"><\/span>Backup the networking file<\/h4>\n<p>It is a good idea to back up the networking file before you make any changes so that it can be quickly reverted if things go wrong. Run the following command to make a backup copy of the file:<\/p>\n<pre class=\"wp-block-code\"><code>sudo cp \/etc\/netplan\/50-cloud-init.yaml \/etc\/netplan\/50-cloud-init.yaml.bak\r\n<\/code><\/pre>\n<p>This will create a file called 00-installer-config.yaml.bak in the \/etc\/netplan\/ folder in case you need it.<\/p>\n<h4><span id=\"Edit_the_00-installer-configyaml_file_to_set_the_static_IP_Address\" class=\"ez-toc-section\"><\/span>Edit the 00-installer-config.yaml file to set the static IP Address<\/h4>\n<p>Edit the 00-installer-config.yaml file in your desired editor<\/p>\n<pre class=\"wp-block-code\"><code>vim \/etc\/netplan\/50-cloud-init.yaml<\/code><\/pre>\n<p><a href=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108915\" src=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-2.png\" alt=\"\" width=\"685\" height=\"498\" \/><\/a><\/p>\n<p>If your server is set to dhcp then you will see something like:<a href=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108917\" src=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-3.png\" alt=\"\" width=\"685\" height=\"498\" \/><\/a><\/p>\n<p>Edit the file to look something like:<\/p>\n<p>Save the file.<\/p>\n<p><a href=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108918\" src=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-4.png\" alt=\"\" width=\"685\" height=\"498\" \/><\/a><a href=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108919\" src=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-5.png\" alt=\"\" width=\"685\" height=\"498\" \/><\/a><\/p>\n<p>Apply the changes:<\/p>\n<pre class=\"wp-block-code\"><code>sudo netplan apply<\/code><\/pre>\n<p><a href=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108920\" src=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-6.png\" alt=\"Statistic IP\" width=\"685\" height=\"498\" \/><\/a>The server will then be using the new address. If you were connected via ssh you will have to open a new session and connect to the NEW IP ADDRESS:<\/p>\n<p><a href=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108923\" src=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-7.png\" alt=\"Statistic IP\" width=\"661\" height=\"418\" \/><\/a><\/p>\n<p>The server will now use this address every time it is rebooted from now on.<\/p>\n<h4>To revert the changes you just need to do the following:<\/h4>\n<p>Over write the edited file with the backup file:<\/p>\n<pre class=\"wp-block-code\"><code>sudo cp \/etc\/netplan\/50-cloud-init.yaml.bak \/etc\/netplan\/50-cloud-init.yaml<\/code><\/pre>\n<p><a href=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108930\" src=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-8.png\" alt=\"Statistic IP\" width=\"661\" height=\"418\" \/><\/a>Reload netplan:<\/p>\n<pre class=\"wp-block-code\"><code>sudo netplan apply<\/code><\/pre>\n<p><a href=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108933\" src=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-9.png\" alt=\"\" width=\"661\" height=\"418\" \/><\/a>The server will now be configured for dhcp and should have its old ip address again:<a href=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108934\" src=\"https:\/\/www.harianaceh.co.id\/media\/2022\/09\/Statistic-IP-10.png\" alt=\"\" width=\"685\" height=\"498\" \/><\/a><\/p>\n<p>The server is now ready to install what ever software that you would like to install. For some ideas of what to install go to our\u00a0Ubuntu Section\u00a0of the site.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We prefer to set a static ip dynamically using my dhcp server but if you prefer to add a static IP address then this can easily be done using the following process:<\/p>\n","protected":false},"author":1,"featured_media":108943,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_disable_autopaging":false},"categories":[98452,61],"tags":[95395,58638,95392,95393,95394],"series":[],"class_list":["post-108910","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorial","category-teknologi","tag-ip-address","tag-ubuntu","tag-static-ip","tag-static-ip-address","tag-dynamic-ip-address"],"_links":{"self":[{"href":"https:\/\/www.harianaceh.co.id\/aplikasi-api\/wp\/v2\/posts\/108910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.harianaceh.co.id\/aplikasi-api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.harianaceh.co.id\/aplikasi-api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.harianaceh.co.id\/aplikasi-api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.harianaceh.co.id\/aplikasi-api\/wp\/v2\/comments?post=108910"}],"version-history":[{"count":0,"href":"https:\/\/www.harianaceh.co.id\/aplikasi-api\/wp\/v2\/posts\/108910\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.harianaceh.co.id\/aplikasi-api\/wp\/v2\/media\/108943"}],"wp:attachment":[{"href":"https:\/\/www.harianaceh.co.id\/aplikasi-api\/wp\/v2\/media?parent=108910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.harianaceh.co.id\/aplikasi-api\/wp\/v2\/categories?post=108910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.harianaceh.co.id\/aplikasi-api\/wp\/v2\/tags?post=108910"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/www.harianaceh.co.id\/aplikasi-api\/wp\/v2\/series?post=108910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}