Edit config:
sudo nano /etc/network/interfaces
Usual default config:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug ens18
iface ens18 inet dhcp
Change to:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug ens18
iface ens18 inet static
address xxx.xxx.xxx.xxx
netmask 255.255.255.0
gateway xxx.xxx.xxx.xxx
dns-nameservers 1.1.1.1 8.8.8.8
1.1.1.1 & 8.8.8.8 are Cloudflare and Google’s free public DNS servers, you can add your own dns server beside these.
Restart network service for changes to take effect:
systemctl restart networking