How to set static ip address on Ubuntu Server

In Ubuntu server 22.04, networking is controlled by netplan utility, so we will use netplan to configure static ip address on Ubuntu server.

Go to the netplan folder

$ cd /etc/netplan
$ ls -l

The name of the .yaml config file may differ depending on your setup. list the contents of the .yaml you see.

Edit the config file

$ sudo nano 00-installer-config.yaml
#DHCP
network:
  ethernets:
    ens33:
      dhcp4: true
  version: 2

#STATIC


network:
  renderer: networkd
  ethernets:
    ens33:
      addresses:
        - 192.168.1.247/24
      nameservers:
        addresses: [4.2.2.2, 8.8.8.8]
      routes:
        - to: default
          via: 192.168.1.1
  version: 2

Apply the change

sudo netplan apply

Powered by BetterDocs