Source: https://tecadmin.net/how-to-configure-static-ip-address-on-ubuntu-22-04/
- Find the Newtwork Interface name
sudo ip aCapture the network interface name. It is NOT the lo but something like eth0 or ens160.
- Create or Edit a Netplan configuration file
sudo vi /etc/netplan/01-netcfg.yamlThe contents should be like this:
network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses:
- 192.168.1.70/24
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
routes:
- to: default
via: 192.168.1.1Notice here the eth0. Replace it with your network interface name. Also, set the static IPv4 address in the addresses
section, with the correct submask bits size (/24 in this case). The correct IP to set depends on your network configuration
so use one that works for you. Also in the routes section, in via, set the correct IPv4 for your Gateway (Router).
- Apply the netplan changes
sudo netplan apply