Setting a Static IP Address in Ubuntu 24.04

See: https://linuxconfig.org/setting-a-static-ip-address-in-ubuntu-24-04-via-the-command-line

First Backup Your network configuration file that contains your DHCP default.

user@svr: cd /etc/netplan [Enter]

user@svr:/etc/netplan$ ls [Enter]
50-cloud-init.yaml

user@svr:/etc/netplan$ sudo cp 50-cloud-init.yaml  50-cloud-init.yaml-bak [Enter]

user@svr:/etc/netplan$ ls [Enter]
50-cloud-init.yaml  50-cloud-init.yaml-bak

Example Configuration for a Static IP. Use Vim or Nano to edit 50-cloud-init.yaml

sudo vim 50-cloud-init.yaml

Edit the file according to the following example, but substituting your network name, Lan IP addresses, Routes (to your router's gateway), and your Nameservers rather than Google's.

network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: no
      addresses:
        - 192.168.1.10/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]

Apply the network changes:

user@svr: /etc/netplan$ sudo netplan apply

Check the status of the network changes:

if config -a

A Great Vim Cheat Sheet

See: https://vimsheet.com/