No Linux No LIfe – How to Apply a Static IP Address in Ubuntu Server 22.04

Linux all the way!!

As I mentioned in some of my past posts, I have three Linux servers running in my home, and two of them are running Ubuntu. Given that servers are something you need to access on a daily basis, it’s advisable to have their IP addresses set as static rather than dynamic. Applying a static IP address to an Ubuntu Server isn’t particularly challenging if you follow the right procedure.

1: Go to directory /etc/netplan/

In /etc/netplan, you may find a file: 00-installer-config.yaml. Make a backup copy of the file juts in case, and then delete the original one.

2: vim 00-installer-config.yaml

As the title suggests, create a file named 00-installer-config.yaml, in which set your preferable IP address just like the one below.

# This is the network config written by 'subiquity'
network:
  ethernets:
    enp1s0:
      dhcp4: no
      addresses: [192.168.0.31/24]
      gateway4: 192.168.0.1
      nameservers:
        addresses: [127.0.0.53]
    enp3s0:
      dhcp4: true
  version: 2

Once you created the file, apply the changes by executing the below command:

sudo netplan apply

Leave a Reply