How to Configure Static IP Address on Ubuntu Server 22.04

In the default network configuration of Ubuntu, dynamic IP addressing is used, which means that the network management daemon in Ubuntu searches for and configures an IP address for the server using the IP address assigned by a DHCP server on the network to which it is connected. When you install Ubuntu server, the network setup is set to static IP addressing by default, which is not ideal. In this chapter, you will learn how to configure a network interface to have a static IP address assigned to it.

Step 1 : Use the following command to get a list of accessible Ethernet interfaces.


Step 2 : Locate the following lines in /etc/netplan/00-installer-config.yaml:


Step 3 : To the preceding lines, add an IP address, a net mask, and a default gateway (replace the samples with the appropriate values) as follows:


Step 4 : If you want to make these modifications permanent, use the following command:


Step 5 : To test the network connection, try pinging a distant host: