How to Configure Static IP Address on Ubuntu Server 22.04 - 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:
dhcp4: true sudo nano /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:
network: ethernets: ens3: addresses: - 192.168.1.95/24 routes: - to: default via: 192.168.1.1 nameservers: addresses: [126.96.36.199,188.8.131.52] dhcp4: no version: 2
Step 4 : If you want to make these modifications permanent, use the following command:
sudo netplan apply
Step 5 : To test the network connection, try pinging a distant host: