This article demonstrates how to set up Ubuntu Server 20.04 with a static IP address after the server installation which defaults to DHCP IP addressing.
In this latest iteration of Ubuntu Server, Canonical decided to use netplan to manage the network configuration and therefore the static IP address set up is a bit different. I expect that you have a Ubuntu Server 20.04 installed and running and if you need help setting one one follow this article.
Lets get started and have a look at the current network configuration by executing the following command:
this should display something similar like the following screenshot.
Since the use on netplan one has to edit yaml files which netplan uses to configure the network interface. Execute the following command:
sudo vim /etc/netplan/00-installer-config.yaml
and it should look like this:
As you clearly can spot this is set up to use DHCP version 4 to automatically configure the network card. Lets make changes to it and set up the IP Address to be 192.168.69.90, the Gateway to be 192.168.69.1 and Name Servers to be 220.127.116.11 & 18.104.22.168. Make change so it looks like the following:
In the next step save the file and try out the new network configuration. Run the following command:
sudo netplan try
After executingthat command you should see something like the following screenshot:
Hit enter to accept that configuration and let run the following commands to see that all is still working.
to check the new configuration was applied
ping the internal gateway to verify network communication is working internally
ping an external ip address to verify external network communication is working
query the public DNS to verify that this part of the network configuration is working as well. If everything is responding as expected without any errors we can go ahead and apply the new netplan configuration for good with the following command:
sudo netplan apply
Lets reboot the server and see that it is indeed all configured correctly and applied even upon reboot of the server. After the reboot is done log back in and run:
it should look like the following:
As you can see even after a server reboot the configuration has been successfully applied.
As you can see the new netplan network configuration is fairly easy and simple. I like it quiet a lot especially the part that you can try it out before completely apply it. If you like to read more about netplan read here. Hopefully this article was useful. Please leave a comment and perhaps provide suggestion for future articles.